From 86470adc229eeee9628aca96ebf5a82a2ae42210 Mon Sep 17 00:00:00 2001 From: Fleny Date: Fri, 24 Jul 2026 19:22:22 +0200 Subject: [PATCH] ci: Simplify GitHub Actions workflows (#5207) * ci: Simplify GitHub Actions workflows * Restore codecov flags using script * use gpgv instead of gpg --verify * Remove verbose * remove test script --- .github/workflows/e2e-test.yml | 43 --- .github/workflows/integration-test.yml | 34 --- .github/workflows/lib-check-e2e.yml | 37 --- .github/workflows/lib-check.yml | 262 ++++++++++-------- .github/workflows/other-runtime-unit-test.yml | 50 ---- .github/workflows/unit-test.yml | 34 --- packages/bot/package.json | 4 +- packages/discordeno/package.json | 2 +- packages/gateway/package.json | 4 +- packages/rest/package.json | 4 +- packages/types/package.json | 2 +- packages/utils/package.json | 2 +- scripts/coveragePathFixing.js | 3 - turbo.json | 6 +- 14 files changed, 163 insertions(+), 324 deletions(-) delete mode 100644 .github/workflows/e2e-test.yml delete mode 100644 .github/workflows/integration-test.yml delete mode 100644 .github/workflows/lib-check-e2e.yml delete mode 100644 .github/workflows/other-runtime-unit-test.yml delete mode 100644 .github/workflows/unit-test.yml delete mode 100644 scripts/coveragePathFixing.js diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml deleted file mode 100644 index dcb6939b6..000000000 --- a/.github/workflows/e2e-test.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: E2E Test -permissions: - contents: read -on: - workflow_call: - inputs: - package: - required: true - type: string - event_name: - required: true - type: string - -jobs: - e2e-test: - name: E2E Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 - with: - node-version: 22 - cache: yarn - - run: yarn install --immutable - - name: Cache for Turbo - uses: rharkor/caching-for-turbo@v2.5.0 - with: - cache-prefix: turbo-cache- - - name: E2E Test - if: ${{ inputs.event_name != 'pull_request' }} - run: yarn test:e2e --filter=./packages/${{ inputs.package }} - env: - DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} - E2E_TEST_GUILD_ID: ${{ secrets.UNIT_TEST_GUILD_ID }} - PROXY_REST_SECRET: ${{ secrets.PROXY_REST_SECRET }} - PROXY_REST_URL: ${{ secrets.PROXY_REST_URL }} - - name: Collect and upload the coverage report - uses: codecov/codecov-action@v7 - if: ${{ inputs.event_name != 'pull_request' }} - with: - files: ./packages/${{ inputs.package }}/coverage/lcov.info - flags: ${{ inputs.package }}-e2e,${{ inputs.package }} - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml deleted file mode 100644 index ae9b08366..000000000 --- a/.github/workflows/integration-test.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Package Test -permissions: - contents: read -on: - workflow_call: - inputs: - package: - required: true - type: string - -jobs: - integration-test: - name: Integration Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 - with: - node-version: 22 - cache: yarn - - run: yarn install --immutable - - name: Cache for Turbo - uses: rharkor/caching-for-turbo@v2.5.0 - with: - cache-prefix: turbo-cache- - - name: Integration Test - run: yarn test:integration --filter=./packages/${{ inputs.package }} - timeout-minutes: 3 - - name: Collect and upload the coverage report - uses: codecov/codecov-action@v7 - with: - files: ./packages/${{ inputs.package }}/coverage/lcov.info - flags: ${{ inputs.package }}-integration,${{ inputs.package }} - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/lib-check-e2e.yml b/.github/workflows/lib-check-e2e.yml deleted file mode 100644 index 1ad249c9b..000000000 --- a/.github/workflows/lib-check-e2e.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Library Checks (E2E) -permissions: - contents: read -on: - pull_request: - push: - branches: - - main - paths-ignore: - - 'website/**' - merge_group: - -jobs: - workqueue: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: ahmadnassri/action-workflow-queue@v1 - if: ${{ github.event_name != 'pull_request' }} - with: - timeout: 6000000 - rest-e2e-test: - needs: workqueue - name: Rest - uses: ./.github/workflows/e2e-test.yml - secrets: inherit - with: - package: rest - event_name: ${{ github.event_name }} - bot-e2e-test: - name: Bot - needs: rest-e2e-test - uses: ./.github/workflows/e2e-test.yml - secrets: inherit - with: - package: bot - event_name: ${{ github.event_name }} diff --git a/.github/workflows/lib-check.yml b/.github/workflows/lib-check.yml index 99ae2b543..b01d94716 100644 --- a/.github/workflows/lib-check.yml +++ b/.github/workflows/lib-check.yml @@ -46,7 +46,6 @@ jobs: format: name: Format runs-on: ubuntu-latest - needs: build-type-and-test steps: - uses: actions/checkout@v7 - uses: actions/setup-node@v7 @@ -81,118 +80,163 @@ jobs: - name: Test Type Test run: yarn test:test-type - # Not using matrix because test later on cant needs a specific job - bot-unit-test: - name: Bot + unit-tests: + name: Unit Tests needs: [build-dist] - uses: ./.github/workflows/unit-test.yml - secrets: inherit - with: - package: bot - # https://github.com/orgs/community/discussions/12835 - # bot-e2e-test: - # name: Bot - # needs: bot-unit-test - # if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'merge_group' }} - # uses: ./.github/workflows/e2e-test.yml - # secrets: inherit - # with: - # package: bot - bot-other-runtime-test: - name: Bot - needs: bot-unit-test - uses: ./.github/workflows/other-runtime-unit-test.yml - secrets: inherit - with: - package: bot + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: yarn + - run: yarn install --immutable + - name: Cache for Turbo + uses: rharkor/caching-for-turbo@v2.5.0 + with: + cache-prefix: turbo-cache- + - run: yarn test:unit + - name: Download and verify codecov cli + run: | + curl https://keybase.io/codecovsecops/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import - discordeno-unit-test: - name: Discordeno - needs: [build-dist] - uses: ./.github/workflows/unit-test.yml - secrets: inherit - with: - package: discordeno - discordeno-other-runtime-test: - name: Discordeno - needs: discordeno-unit-test - uses: ./.github/workflows/other-runtime-unit-test.yml - secrets: inherit - with: - package: discordeno + curl -Os https://cli.codecov.io/latest/linux/codecov + curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM + curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig + gpgv codecov.SHA256SUM.sig codecov.SHA256SUM - gateway-unit-test: - name: Gateway - needs: [build-dist] - uses: ./.github/workflows/unit-test.yml - secrets: inherit - with: - package: gateway - gateway-integration-test: - name: Gateway - needs: build-dist - uses: ./.github/workflows/integration-test.yml - secrets: inherit - with: - package: gateway - gateway-other-runtime-test: - name: Gateway - needs: [gateway-unit-test] - uses: ./.github/workflows/other-runtime-unit-test.yml - secrets: inherit - with: - package: gateway + shasum -a 256 -c codecov.SHA256SUM + sudo chmod +x codecov + - name: Upload coverage report to codecov + run: | + find packages/ -name "lcov.info" -type f | awk -F'/' '{ print $2 }' | while read -r package; do + sed -i "s|SF:src|SF:packages/${package}/src|g" "packages/$package/coverage/lcov.info" - rest-unit-test: - name: Rest - needs: [build-dist] - uses: ./.github/workflows/unit-test.yml - secrets: inherit - with: - package: rest - # https://github.com/orgs/community/discussions/12835 - # rest-e2e-test: - # name: Rest - # needs: rest-unit-test - # if: ${{ github.ref == 'refs/heads/main' || github.event_name == 'merge_group' }} - # uses: ./.github/workflows/e2e-test.yml - # secrets: inherit - # with: - # package: rest - rest-other-runtime-test: - name: Rest - needs: rest-unit-test - uses: ./.github/workflows/other-runtime-unit-test.yml - secrets: inherit - with: - package: rest + echo "Uploading $package converage/lcov.info file" + ./codecov upload-process --disable-search --token ${{ secrets.CODECOV_TOKEN }} \ + --fail-on-error --git-service github --sha $(git rev-parse HEAD) \ + --file packages/$package/coverage/lcov.info --flag $package-unit --flag $package + done - types-unit-test: - name: Types - needs: [build-dist] - uses: ./.github/workflows/unit-test.yml - secrets: inherit - with: - package: types - types-other-runtime-test: - name: Types - needs: types-unit-test - uses: ./.github/workflows/other-runtime-unit-test.yml - secrets: inherit - with: - package: types + unit-tests-deno: + name: Deno Unit Tests + needs: [build-dist, unit-tests] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: yarn + - uses: denoland/setup-deno@v2 + with: + deno-version: 'v2.9.x' + - run: yarn install --immutable + - name: Cache for Turbo + uses: rharkor/caching-for-turbo@v2.5.0 + with: + cache-prefix: turbo-cache- + - run: yarn test:deno-unit - utils-unit-test: - name: Utils + unit-tests-bun: + name: Bun Unit Tests + needs: [build-dist, unit-tests] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: yarn + - uses: oven-sh/setup-bun@v2 + with: + bun-version: '1.3.14' + - run: yarn install --immutable + - name: Cache for Turbo + uses: rharkor/caching-for-turbo@v2.5.0 + with: + cache-prefix: turbo-cache- + - run: yarn test:bun-unit + + integration-tests: + name: Integration Tests needs: [build-dist] - uses: ./.github/workflows/unit-test.yml - secrets: inherit - with: - package: utils - utils-other-runtime-test: - name: Utils - needs: utils-unit-test - uses: ./.github/workflows/other-runtime-unit-test.yml - secrets: inherit - with: - package: utils + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: yarn + - run: yarn install --immutable + - name: Cache for Turbo + uses: rharkor/caching-for-turbo@v2.5.0 + with: + cache-prefix: turbo-cache- + - run: yarn test:integration + - name: Download and verify codecov cli + run: | + curl https://keybase.io/codecovsecops/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import + + curl -Os https://cli.codecov.io/latest/linux/codecov + curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM + curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig + gpgv codecov.SHA256SUM.sig codecov.SHA256SUM + + shasum -a 256 -c codecov.SHA256SUM + sudo chmod +x codecov + - name: Upload coverage report to codecov + run: | + find packages/ -name "lcov.info" -type f | awk -F'/' '{ print $2 }' | while read -r package; do + sed -i "s|SF:src|SF:packages/${package}/src|g" "packages/$package/coverage/lcov.info" + + echo "Uploading $package converage/lcov.info file" + ./codecov upload-process --disable-search --token ${{ secrets.CODECOV_TOKEN }} \ + --fail-on-error --git-service github --sha $(git rev-parse HEAD) \ + --file packages/$package/coverage/lcov.info --flag $package-integration --flag $package + done + + e2e-tests: + name: E2E Tests + needs: [build-dist] + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' + concurrency: + group: e2e-tests + queue: max + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-node@v7 + with: + node-version: 22 + cache: yarn + - run: yarn install --immutable + - name: Cache for Turbo + uses: rharkor/caching-for-turbo@v2.5.0 + with: + cache-prefix: turbo-cache- + - run: yarn test:e2e + env: + DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }} + E2E_TEST_GUILD_ID: ${{ secrets.UNIT_TEST_GUILD_ID }} + - name: Download and verify codecov cli + run: | + curl https://keybase.io/codecovsecops/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import + + curl -Os https://cli.codecov.io/latest/linux/codecov + curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM + curl -Os https://cli.codecov.io/latest/linux/codecov.SHA256SUM.sig + gpgv codecov.SHA256SUM.sig codecov.SHA256SUM + + shasum -a 256 -c codecov.SHA256SUM + sudo chmod +x codecov + - name: Upload coverage report to codecov + run: | + find packages/ -name "lcov.info" -type f | awk -F'/' '{ print $2 }' | while read -r package; do + sed -i "s|SF:src|SF:packages/${package}/src|g" "packages/$package/coverage/lcov.info" + + echo "Uploading $package converage/lcov.info file" + ./codecov upload-process --disable-search --token ${{ secrets.CODECOV_TOKEN }} \ + --fail-on-error --git-service github --sha $(git rev-parse HEAD) \ + --file packages/$package/coverage/lcov.info --flag $package-e2e --flag $package + done diff --git a/.github/workflows/other-runtime-unit-test.yml b/.github/workflows/other-runtime-unit-test.yml deleted file mode 100644 index e580f66c1..000000000 --- a/.github/workflows/other-runtime-unit-test.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Other Runtime Package Test -permissions: - contents: read -on: - workflow_call: - inputs: - package: - required: true - type: string - -jobs: - deno-unit-test: - name: Deno Unit Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 - with: - node-version: 22 - cache: yarn - - uses: denoland/setup-deno@v2 - with: - deno-version: 'v2.9.x' - - run: yarn install --immutable - - name: Cache for Turbo - uses: rharkor/caching-for-turbo@v2.5.0 - with: - cache-prefix: turbo-cache- - - name: Deno Unit Test - run: yarn test:deno-unit --filter=./packages/${{ inputs.package }} - bun-unit-test: - name: Bun Unit Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 - with: - node-version: 22 - cache: yarn - - uses: oven-sh/setup-bun@v2 - with: - bun-version: '1.3.14' - - run: yarn install --immutable - - name: Cache for Turbo - uses: rharkor/caching-for-turbo@v2.5.0 - with: - cache-prefix: turbo-cache- - - name: Bun Unit Test - run: yarn test:bun-unit --filter=./packages/${{ inputs.package }} - timeout-minutes: 1 diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml deleted file mode 100644 index 4fb8f3335..000000000 --- a/.github/workflows/unit-test.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Package Test -permissions: - contents: read -on: - workflow_call: - inputs: - package: - required: true - type: string - -jobs: - unit-test: - name: Unit Test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v7 - - uses: actions/setup-node@v7 - with: - node-version: 22 - cache: yarn - - run: yarn install --immutable - - name: Cache for Turbo - uses: rharkor/caching-for-turbo@v2.5.0 - with: - cache-prefix: turbo-cache- - - name: Unit Test - run: yarn test:unit --filter=./packages/${{ inputs.package }} - timeout-minutes: 1 - - name: Collect and upload the coverage report - uses: codecov/codecov-action@v7 - with: - files: ./packages/${{ inputs.package }}/coverage/lcov.info - flags: ${{ inputs.package }}-unit,${{ inputs.package }} - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/packages/bot/package.json b/packages/bot/package.json index 0b9767083..8b8f28deb 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -17,10 +17,10 @@ "build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist", "release-build": "yarn build && yarn build:type", "check": "biome check --write", - "test:unit": "c8 -r lcov mocha 'tests/unit/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js bot", + "test:unit": "c8 -r lcov mocha 'tests/unit/**/*.spec.ts'", "test:deno-unit": "deno -A npm:mocha 'tests/unit/**/*.spec.ts'", "test:bun-unit": "bun --bun mocha 'tests/unit/**/*.spec.ts'", - "test:e2e": "c8 -r lcov mocha -t 30000 'tests/e2e/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js bot", + "test:e2e": "c8 -r lcov mocha -t 30000 'tests/e2e/**/*.spec.ts'", "test:test-type": "tsc --project tests/tsconfig.json", "test:type": "tsc --noEmit" }, diff --git a/packages/discordeno/package.json b/packages/discordeno/package.json index c5102e9b5..da51ed1aa 100644 --- a/packages/discordeno/package.json +++ b/packages/discordeno/package.json @@ -17,7 +17,7 @@ "build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist", "release-build": "yarn build && yarn build:type", "check": "biome check --write", - "test:unit": "c8 -r lcov mocha 'tests/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js discordeno", + "test:unit": "c8 -r lcov mocha 'tests/**/*.spec.ts'", "test:deno-unit": "deno -A npm:mocha 'tests/**/*.spec.ts'", "test:bun-unit": "bun --bun mocha 'tests/**/*.spec.ts'", "test:test-type": "tsc --project tests/tsconfig.json", diff --git a/packages/gateway/package.json b/packages/gateway/package.json index 6146e2087..016a2bd6e 100644 --- a/packages/gateway/package.json +++ b/packages/gateway/package.json @@ -17,10 +17,10 @@ "build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist", "release-build": "yarn build && yarn build:type", "check": "biome check --write", - "test:unit": "c8 -r lcov mocha 'tests/unit/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js gateway", + "test:unit": "c8 -r lcov mocha 'tests/unit/**/*.spec.ts'", "test:deno-unit": "deno -A npm:mocha 'tests/unit/**/*.spec.ts'", "test:bun-unit": "bun --bun mocha 'tests/unit/**/*.spec.ts'", - "test:integration": "c8 -r lcov mocha -t 15000 'tests/integration/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js gateway", + "test:integration": "c8 -r lcov mocha -t 15000 'tests/integration/**/*.spec.ts'", "test:test-type": "tsc --project tests/tsconfig.json", "test:type": "tsc --noEmit" }, diff --git a/packages/rest/package.json b/packages/rest/package.json index 021af5ff0..1aa1647ed 100644 --- a/packages/rest/package.json +++ b/packages/rest/package.json @@ -17,10 +17,10 @@ "build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist", "release-build": "yarn build && yarn build:type", "check": "biome check --write", - "test:unit": "c8 -r lcov mocha 'tests/unit/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js rest", + "test:unit": "c8 -r lcov mocha 'tests/unit/**/*.spec.ts'", "test:deno-unit": "deno -A npm:mocha 'tests/unit/**/*.spec.ts'", "test:bun-unit": "bun --bun mocha 'tests/unit/**/*.spec.ts'", - "test:e2e": "c8 -r lcov mocha -t 60000 'tests/e2e/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js rest", + "test:e2e": "c8 -r lcov mocha -t 60000 'tests/e2e/**/*.spec.ts'", "test:test-type": "tsc --project tests/tsconfig.json", "test:type": "tsc --noEmit" }, diff --git a/packages/types/package.json b/packages/types/package.json index ec101f185..dfe036ad5 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -17,7 +17,7 @@ "build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist", "release-build": "yarn build && yarn build:type", "check": "biome check --write", - "test:unit": "c8 -r lcov mocha 'tests/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js types", + "test:unit": "c8 -r lcov mocha 'tests/**/*.spec.ts'", "test:deno-unit": "deno -A npm:mocha 'tests/**/*.spec.ts'", "test:bun-unit": "bun --bun mocha 'tests/**/*.spec.ts'", "test:test-type": "tsc --project tests/tsconfig.json", diff --git a/packages/utils/package.json b/packages/utils/package.json index 925fb01b6..43b4c0a9f 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -17,7 +17,7 @@ "build:type": "tsc --declaration --emitDeclarationOnly --declarationDir dist", "release-build": "yarn build && yarn build:type", "check": "biome check --write", - "test:unit": "c8 -r lcov mocha 'tests/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js utils", + "test:unit": "c8 -r lcov mocha 'tests/**/*.spec.ts'", "test:deno-unit": "deno -A npm:mocha 'tests/**/*.spec.ts'", "test:bun-unit": "bun --bun mocha 'tests/**/*.spec.ts'", "test:test-type": "tsc --project tests/tsconfig.json", diff --git a/scripts/coveragePathFixing.js b/scripts/coveragePathFixing.js deleted file mode 100644 index d6ec62a41..000000000 --- a/scripts/coveragePathFixing.js +++ /dev/null @@ -1,3 +0,0 @@ -import { readFileSync, writeFileSync } from 'node:fs'; - -writeFileSync('./coverage/lcov.info', readFileSync('./coverage/lcov.info', 'utf-8').replace(/SF:src/g, `SF:packages/${process.argv[2]}/src`)); diff --git a/turbo.json b/turbo.json index a9c2c53b9..3ad539ea4 100644 --- a/turbo.json +++ b/turbo.json @@ -36,7 +36,7 @@ "outputs": ["coverage/**"] }, "test:e2e": { - "dependsOn": ["^build"], + "dependsOn": ["^build", "^test:e2e"], "inputs": ["src/**/*.ts", "tests/e2e**/*.spec.ts"], "outputs": ["coverage/**"], "env": ["DISCORD_TOKEN", "E2E_TEST_GUILD_ID"] @@ -49,10 +49,6 @@ "dependsOn": ["^build:type"], "inputs": ["src/**/*.ts"] }, - "check": { - "dependsOn": ["build:type"], - "cache": false - }, "build:doc": { // NOTE: This task can only be run with "--singe-package" in the flags to turbo, as it is defined only in the root package.json "inputs": ["packages/**/src/**/*.ts"],