Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/test-e2e-cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ jobs:
timeout-minutes: 1
- uses: actions/setup-node@v3.5.1
with:
node-version: "18.16"
- run: npm i -g yarn@1.22.19
- run: yarn --frozen-lockfile
node-version: "22"
- run: yarn --immutable
- run: yarn test:e2e
timeout-minutes: 10
5 changes: 2 additions & 3 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ jobs:
timeout-minutes: 1
- uses: actions/setup-node@v3.5.1
with:
node-version: "18.16"
- run: npm i -g yarn@1.22.19
- run: yarn --frozen-lockfile
node-version: "22"
- run: yarn --immutable
- run: yarn test:e2e
timeout-minutes: 10
5 changes: 4 additions & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3.3.0
- run: yarn --frozen-lockfile
- uses: actions/setup-node@v3.5.1
with:
node-version: 22
- run: yarn --immutable
- run: yarn test:integration --verbose
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ npm-debug.log
.env
.eslintcache
yarn-error.log
.yarn/install-state.gz
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ check-linting:
<<: *common-refs
<<: *kubernetes-env
script:
- yarn --frozen-lockfile
- yarn --immutable
- yarn lint

test-unit:
stage: test
<<: *common-refs
<<: *kubernetes-env
script:
- yarn --frozen-lockfile
- yarn --immutable
- yarn test

build-docker-bot:
Expand Down
894 changes: 894 additions & 0 deletions .yarn/releases/yarn-4.3.0.cjs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
yarnPath: .yarn/releases/yarn-4.3.0.cjs
nodeLinker: node-modules
29 changes: 16 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
FROM node:18-alpine
FROM node:22-alpine as builder

WORKDIR /usr/src/app

COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn/ ./.yarn/
RUN yarn install --immutable
COPY tsconfig.json ./
COPY src/ ./src

RUN yarn build

FROM node:22-slim

# metadata
ARG VCS_REF=master
Expand All @@ -15,20 +27,11 @@ LABEL io.parity.image.authors="cicd-team@parity.io" \
io.parity.image.revision="${VCS_REF}" \
io.parity.image.created="${BUILD_DATE}"

RUN apk -U upgrade --no-cache && apk add --no-cache git

WORKDIR /usr/src/app

COPY package.json ./
COPY yarn.lock ./
RUN yarn install --frozen-lockfile
COPY tsconfig.json ./
COPY src/ ./src

RUN yarn build

# Purge the devDeps required for building
RUN yarn install --production
COPY --from=builder /usr/src/app/package.json ./
COPY --from=builder /usr/src/app/dist ./dist/
COPY --from=builder /usr/src/app/node_modules ./node_modules/

ENV NODE_ENV="production"

Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
moduleNameMapper: { "^src/(.*)": `${__dirname}/src/$1` },
moduleNameMapper: { "^#src/(.*)": `${__dirname}/src/$1` },
preset: "ts-jest",
testEnvironment: "node",
roots: ["./src"],
Expand Down
10 changes: 0 additions & 10 deletions nodemon.json

This file was deleted.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,46 @@
],
"scripts": {
"typecheck": "tsc --noEmit",
"lint": "yarn eslint --quiet '{*,**/*}.{js,ts}' && yarn prettier --check '{*,**/*}.json' && yarn typecheck",
"fix:eslint": "eslint --fix",
"fix:prettier": "prettier --write",
"lint": "npx eslint --quiet '{*,**/*}.{js,ts}' && npx prettier --check '{*,**/*}.json' && yarn typecheck",
"fix:eslint": "npx eslint --fix",
"fix:prettier": "npx prettier --write",
"fix": "yarn fix:eslint '{*,**/*}.{js,ts}' && yarn fix:prettier '{*,**/*}.json'",
"start": "nodemon",
"start": "concurrently \"tsc -w\" \"node --watch dist/bot.js\"",
"build": "rimraf dist; tsc",
"test": "NODE_OPTIONS='--experimental-vm-modules --es-module-specifier-resolution=node' jest",
"test:integration": "NODE_OPTIONS='--experimental-vm-modules --es-module-specifier-resolution=node' jest -c jest.integration.config.js",
"test:e2e": "NODE_OPTIONS='--experimental-vm-modules --es-module-specifier-resolution=node' jest -c jest.e2e.config.js"
"test": "jest",
"test:integration": "jest -c jest.integration.config.js",
"test:e2e": "jest -c jest.e2e.config.js"
},
"imports": {
"#src/*": "./src/*.js"
},
"dependencies": {
"@eng-automation/integrations": "^4.1.0",
"@eng-automation/js": "^0.0.22",
"@eng-automation/integrations": "^4.4.0",
"@eng-automation/js": "^2.2.0",
"@polkadot/api": "^10.9.1",
"@polkadot/util": "^12.3.2",
"@polkadot/util-crypto": "^12.3.2",
"concurrently": "^8.2.2",
"ethers": "^5.7.2",
"matrix-js-sdk": "^26.1.0",
"node-fetch": "^2.6.12",
"probot": "^12.2.8",
"prom-client": "^14.2.0"
},
"devDependencies": {
"@eng-automation/js-style": "^2.1.0",
"@eng-automation/js-style": "^3.1.0",
"@polkadot/keyring": "^12.3.2",
"@resolritter/tsc-files": "^1.1.4",
"@types/jest": "^29.5.5",
"@types/node": "^18.16.18",
"@types/node-fetch": "^2",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.2",
"dotenv": "^16.0.1",
"jest": "^29.7.0",
"nodemon": "^2.0.13",
"rimraf": "^3.0.2",
"smee-client": "^1.2.2",
"testcontainers": "^10.2.1",
"ts-jest": "^29.0.5",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"ts-jest": "^29.1.4",
"typescript": "^5.4.5"
},
"engines": {
"node": "^18"
}
"node": "^22"
},
"packageManager": "yarn@4.3.0"
}
6 changes: 5 additions & 1 deletion src/bot-handle-comment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { github } from "@eng-automation/integrations";
import { GitHubInstance } from "@eng-automation/integrations/dist/github/types";
import { envVar } from "@eng-automation/js";
import { IssueCommentCreatedEvent } from "@octokit/webhooks-types";

Expand Down Expand Up @@ -28,7 +29,10 @@ export const handleIssueCommentCreated = async (state: State, event: IssueCommen
await github.getRepoInstallation({ owner: event.repository.owner.login, repo: event.repository.name })
).id;

const octokitInstance = await github.getInstance({
// The "Unsafe assignment of an error typed value" error here goes deep into octokit types, that are full of `any`s
// I wasn't able to get around it
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const octokitInstance: GitHubInstance = await github.getInstance({
authType: "installation",
appId: envVar("GITHUB_APP_ID"),
installationId: String(installationId),
Expand Down
4 changes: 2 additions & 2 deletions src/bot-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { envVar } from "@eng-automation/js";
import { Keyring } from "@polkadot/api";
import { cryptoWaitReady } from "@polkadot/util-crypto";
import { createClient } from "matrix-js-sdk";
import { ApplicationFunction, Probot } from "probot";
import { ApplicationFunction, Context, Probot } from "probot";

import { updateAllBalances } from "./balance";
import { handleIssueCommentCreated } from "./bot-handle-comment";
Expand Down Expand Up @@ -48,7 +48,7 @@ export const botInitialize: AsyncApplicationFunction = async (bot: Probot, { get

bot.log.info("Tip bot was loaded!");

bot.on("issue_comment.created", async (context) => {
bot.on("issue_comment.created", async (context: Context<"issue_comment.created">) => {
await handleIssueCommentCreated(state, context.payload);
});

Expand Down
5 changes: 2 additions & 3 deletions src/polkassembly/polkassembly-moonbase.integration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import "@polkadot/api-augment";
import { logMock } from "#src/testUtil";
import { formatReason } from "#src/util";
import { Wallet } from "ethers";

import { logMock } from "src/testUtil";
import { formatReason } from "src/util";

import { Polkassembly } from "./polkassembly";

/**
Expand Down
3 changes: 1 addition & 2 deletions src/polkassembly/polkassembly.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import "@polkadot/api-augment";
import { Keyring } from "@polkadot/api";
import type { KeyringPair } from "@polkadot/keyring/types";
import { cryptoWaitReady, randomAsU8a } from "@polkadot/util-crypto";

import { logMock } from "src/testUtil";
import { logMock } from "#src/testUtil";

import { Polkassembly } from "./polkassembly";

Expand Down
4 changes: 1 addition & 3 deletions src/polkassembly/polkassembly.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { KeyringPair } from "@polkadot/keyring/types";
import { stringToU8a } from "@polkadot/util";
import { Wallet } from "ethers";
import fetch from "node-fetch";
import type { Probot } from "probot";

const headers = { "Content-Type": "application/json" };
Expand Down Expand Up @@ -128,8 +127,7 @@ export class Polkassembly {
if ((e as Error).message.includes("Please sign up")) {
await this.signup(network);
} else {
this.log.error("loginOrSignup to Polkassembly failed.");
this.log.error(e.message);
this.log.error(e, "loginOrSignup to Polkassembly failed.");
throw e;
}
}
Expand Down
10 changes: 7 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@
"allowJs": true,
"moduleResolution": "node",
"module": "commonjs",
"target": "ES2021",
"lib": ["ES2021"],
"target": "ES2022",
"lib": ["ES2022"],
"strict": true,
"noEmitOnError": true,
"noImplicitAny": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"useUnknownInCatchVariables": false,
"types": ["node", "jest"],
"typeRoots": ["./node_modules/@types", "./src"]
"typeRoots": ["./node_modules/@types", "./src"],
"paths": {
"#src/*": ["./src/*"]
}
},
"include": ["src/**/*"],
"exclude": ["node_modules/**/*"]
Expand Down
Loading