Skip to content

Commit

Permalink
Merge pull request #9595 from hicommonwealth/tim/update-CI
Browse files Browse the repository at this point in the history
  • Loading branch information
timolegros authored Oct 18, 2024
2 parents a813955 + a179e19 commit f918621
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 88 deletions.
119 changes: 34 additions & 85 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ jobs:
run: cd packages/commonwealth && ./scripts/detect-broken-ts-expect-error.sh

# These tests run quickly, so run them in a separate job
commonwealth-unit-integration:
name: Commonwealth Unit And Integration Tests
commonwealth-integration-test:
name: Commonwealth Integration Tests
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
Expand Down Expand Up @@ -336,39 +336,13 @@ jobs:
- name: Build
run: pnpm -r build

- name: Run unit tests
run: pnpm -r test -- --allowOnly=false

- name: Change permissions of coverage files
run: |
chmod -R 755 ./libs/adapters/coverage/lcov.info
chmod -R 755 ./libs/core/coverage/lcov.info
chmod -R 755 ./libs/model/coverage/lcov.info
chmod -R 755 ./libs/sitemaps/coverage/lcov.info
chmod -R 755 ./packages/commonwealth/coverage/lcov.info
chmod -R 755 ./packages/scripts/coverage/lcov.info
- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
flag-name: unit-test-coverage
parallel: true
files: libs/adapters/coverage/lcov.info libs/core/coverage/lcov.info libs/model/coverage/lcov.info libs/sitemaps/coverage/lcov.info packages/commonwealth/coverage/lcov.info packages/scripts/coverage/lcov.info

- name: Run integration tests
run: pnpm -F commonwealth test-integration --allowOnly=false

- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
flag-name: integration-test-coverage
parallel: true
files: ./packages/commonwealth/coverage/lcov.info

commonwealth-evm-tests:
name: EVM Devnet Tests
commonwealth-unit-tests:
name: Commonwealth Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20
strategy:
matrix:
node: [ 20 ]
Expand All @@ -393,30 +367,41 @@ jobs:
image: redis:latest
ports:
- 6379:6379
rabbitmq:
image: rabbitmq:3.11-management
ports:
- 5672:5672
- 15672:15672

steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- name: Run unit tests
run: pnpm -r test -- --allowOnly=false

- name: Run EVM Devnet tests
run: pnpm -F commonwealth test-devnet:evm --allowOnly=false
- name: Change permissions of coverage files
run: |
chmod -R 755 ./libs/adapters/coverage/lcov.info
chmod -R 755 ./libs/core/coverage/lcov.info
chmod -R 755 ./libs/model/coverage/lcov.info
chmod -R 755 ./libs/sitemaps/coverage/lcov.info
- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
flag-name: evm-devnet-test-coverage
flag-name: unit-test-coverage
parallel: true
files: packages/commonwealth/coverage/lcov.info
files: libs/adapters/coverage/lcov.info libs/core/coverage/lcov.info libs/model/coverage/lcov.info libs/sitemaps/coverage/lcov.info

# These tests run slowly, so run them in a separate job
commonwealth-cosmos-tests:
name: Cosmos Devnet Tests

commonwealth-evm-tests:
name: EVM Devnet Tests
runs-on: ubuntu-latest
timeout-minutes: 25
timeout-minutes: 10
strategy:
matrix:
node: [ 20 ]
Expand All @@ -437,69 +422,34 @@ jobs:
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
cosmos_test_app:
image: mhagel1/csdk-v1
ports:
- 5051:5051
cosmos_beta_test_app:
image: mhagel1/csdk-beta
ports:
- 5050:5050
evmos_test_app:
image: mhagel1/evmos-dev
ports:
- 5052:5052
redis:
image: redis:latest
ports:
- 6379:6379

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
with:
node-version: ${{ matrix.node }}

## Cosmos Section:
# We only run Cosmos devnet tests if any files in the following folders changes
- name: Get changed Cosmos devnet-related files
id: changed-files-specific
uses: tj-actions/changed-files@v35
with:
files: |
packages/commonwealth/test/devnet/cosmos/**/*
packages/commonwealth/server/cosmos-gov-notifications/**/*
packages/commonwealth/test/integration/cosmosGovNotifGenerator.spec.ts
packages/commonwealth/server/util/cosmosProxy.ts
packages/commonwealth/client/scripts/controllers/chain/cosmos/gov/**/*
packages/commonwealth/test/util/cosmos-chain-testing/**/*
libs/chains/src/cosmos-ts/**/*
- name: Run following steps if any file(s) in the Cosmos folders change
if: steps.changed-files-specific.outputs.all_changed_files
run: |
echo "One or more Cosmos Devnet-related files has changed."
echo "List all the files that have changed: ${{ steps.changed-files-specific.outputs.all_changed_files }}"
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run Cosmos Devnet tests
if: steps.changed-files-specific.outputs.any_changed == 'true'
run: |
pnpm -F commonwealth start &
(pnpm -F commonwealth wait-server && pnpm -F commonwealth test-devnet:cosmos --allowOnly=false)
- name: Run EVM Devnet tests
run: pnpm -F commonwealth test-devnet:evm --allowOnly=false

- name: Coveralls parallel
if: steps.changed-files-specific.outputs.all_changed_files
uses: coverallsapp/github-action@v2
with:
flag-name: cosmos-devnet-test-coverage
flag-name: evm-devnet-test-coverage
parallel: true
files: packages/commonwealth/coverage/lcov.info

report-coverage:
name: Upload Test Coverage Report
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [ commonwealth-cosmos-tests, commonwealth-evm-tests, commonwealth-unit-integration, e2e-tests-serial, e2e-tests-Parallel, e2e-tests-Mature ]
needs: [ commonwealth-evm-tests, commonwealth-unit-tests ]
if: always()
strategy:
matrix:
Expand All @@ -509,5 +459,4 @@ jobs:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
parallel-finished: true
carryforward: "cosmos-devnet-test-coverage"
parallel-finished: true
2 changes: 1 addition & 1 deletion packages/commonwealth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"test-e2e-mature": "NODE_OPTIONS='--import tsx/esm' NODE_ENV=test TEST_ENV=playwright npx playwright test -c ./test/e2e/playwright.config.ts --workers 1 ./test/e2e/mature/*",
"test-e2e-serial": "NODE_OPTIONS='--import tsx/esm' NODE_ENV=test TEST_ENV=playwright npx playwright test --workers 1 ./test/e2e/e2eSerial/*",
"test-integration": "INIT_TEST_DB=true NODE_ENV=test vitest --config ../../vite.config.ts --fileParallelism=false --coverage run ./test/integration",
"test-unit": "NODE_ENV=test FEATURE_FLAG_GROUP_CHECK_ENABLED=true vitest --config ../../vite.config.ts --coverage run test/unit",
"test-unit": "NODE_ENV=test FEATURE_FLAG_GROUP_CHECK_ENABLED=true vitest --config ../../vite.config.ts run test/unit",
"test-select": "INIT_TEST_DB=true NODE_ENV=test vitest --config ../../vite.config.ts --fileParallelism=false run",
"test-select:watch": "INIT_TEST_DB=true NODE_ENV=test vitest --config ../../vite.config.ts --fileParallelism=false",
"ts-exec": "tsx ",
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "tsc -b ./tsconfig.build.json",
"clean": "rm -rf build && rm -rf coverage",
"check-types": "tsc --noEmit",
"test": "NODE_ENV=test vitest --config ../../vite.config.ts --coverage run test",
"test": "echo No tests for packages/scripts",
"test-dev": "NODE_ENV=test vitest --config ../../vite.config.ts test",
"generate-stakeholder-groups": "tsx src/generate-stakeholder-groups",
"lint": "NODE_OPTIONS=\"--max-old-space-size=4096\" eslint -c ../../.eslintrc.cjs './src/**/*.{ts,tsx}'",
Expand Down
3 changes: 2 additions & 1 deletion packages/scripts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"references": [
{ "path": "../../libs/core/tsconfig.build.json" },
{ "path": "../../libs/model/tsconfig.build.json" },
{ "path": "../../libs/sitemaps/tsconfig.build.json" }
{ "path": "../../libs/sitemaps/tsconfig.build.json" },
{ "path": "../../libs/adapters/tsconfig.build.json" }
]
}

0 comments on commit f918621

Please sign in to comment.