Skip to content

Commit

Permalink
ci: rework chain type matrix in CI runs (blockscout#9704)
Browse files Browse the repository at this point in the history
* ci: remove polygon edge and suave from CI runs

* ci: run chain type workflows based on pr labels

* chore: keep suave and polygon_edge as optional

* ci: update matrix selection logic

* ci: re-run ci if PR is relabeled

* ci: fix default chain type

* ci: refactor default chain types
  • Loading branch information
k1rill-fedoseev authored Apr 3, 2024
1 parent ea97da9 commit 92ac44c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
40 changes: 31 additions & 9 deletions .github/workflows/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ on:
- 'docker/*'
- 'docker-compose/*'
pull_request:
types: [opened, synchronize, reopened, labeled]
branches:
- master
- production-optimism
Expand All @@ -46,9 +47,30 @@ jobs:
steps:
- id: set-matrix
run: |
echo "matrix=$matrixStringifiedObject" >> $GITHUB_OUTPUT
env:
matrixStringifiedObject: '{"chain-type": ["ethereum", "polygon_edge", "polygon_zkevm", "rsk", "suave", "stability", "filecoin", "optimism"]}'
echo "matrix=$(node -e '
// Add/remove CI matrix chain types here
const defaultChainTypes = ["default"];
const chainTypes = ["ethereum", "polygon_zkevm", "rsk", "stability", "filecoin", "optimism"];
const extraChainTypes = ["suave", "polygon_edge"];
// Chain type matrix we use in master branch
const allChainTypes = [].concat(defaultChainTypes, chainTypes, extraChainTypes);
const labels = ${{ github.event_name == 'pull_request' && toJson(github.event.pull_request.labels.*.name) || '[]' }};
const ciLabels = labels.filter(label => label.startsWith("ci:"));
const labeledChainTypes = [].concat(
defaultChainTypes.filter(chainType => ciLabels.includes("ci:" + chainType)),
chainTypes.filter(chainType => ciLabels.includes("ci:all") || ciLabels.includes("ci:" + chainType)),
extraChainTypes.filter(chainType => ciLabels.includes("ci:" + chainType))
);
// Chain type matrix we use in PRs to master branch
const ciChainTypes = labeledChainTypes.length > 0 ? labeledChainTypes : defaultChainTypes;
const matrix = { "chain-type": ${{ github.event_name == 'pull_request' && 'ciChainTypes' || 'allChainTypes' }} };
console.log(JSON.stringify(matrix));
')" >> $GITHUB_OUTPUT
build-and-cache:
name: Build and Cache deps
Expand Down Expand Up @@ -215,12 +237,12 @@ jobs:
mkdir -p priv/plts
mix dialyzer --plt
env:
CHAIN_TYPE: ${{ matrix.chain-type }}
CHAIN_TYPE: ${{ matrix.chain-type != 'default' && matrix.chain-type || '' }}

- name: Run Dialyzer
run: mix dialyzer --halt-exit-status
env:
CHAIN_TYPE: ${{ matrix.chain-type }}
CHAIN_TYPE: ${{ matrix.chain-type != 'default' && matrix.chain-type || '' }}

gettext:
name: Missing translation keys check
Expand Down Expand Up @@ -486,7 +508,7 @@ jobs:
PGUSER: postgres
ETHEREUM_JSONRPC_CASE: "EthereumJSONRPC.Case.Nethermind.Mox"
ETHEREUM_JSONRPC_WEB_SOCKET_CASE: "EthereumJSONRPC.WebSocket.Case.Mox"
CHAIN_TYPE: "${{ matrix.chain-type }}"
CHAIN_TYPE: ${{ matrix.chain-type != 'default' && matrix.chain-type || '' }}
test_nethermind_mox_explorer:
strategy:
fail-fast: false
Expand Down Expand Up @@ -560,7 +582,7 @@ jobs:
PGUSER: postgres
ETHEREUM_JSONRPC_CASE: "EthereumJSONRPC.Case.Nethermind.Mox"
ETHEREUM_JSONRPC_WEB_SOCKET_CASE: "EthereumJSONRPC.WebSocket.Case.Mox"
CHAIN_TYPE: "${{ matrix.chain-type }}"
CHAIN_TYPE: ${{ matrix.chain-type != 'default' && matrix.chain-type || '' }}
test_nethermind_mox_indexer:
strategy:
fail-fast: false
Expand Down Expand Up @@ -626,7 +648,7 @@ jobs:
PGUSER: postgres
ETHEREUM_JSONRPC_CASE: "EthereumJSONRPC.Case.Nethermind.Mox"
ETHEREUM_JSONRPC_WEB_SOCKET_CASE: "EthereumJSONRPC.WebSocket.Case.Mox"
CHAIN_TYPE: "${{ matrix.chain-type }}"
CHAIN_TYPE: ${{ matrix.chain-type != 'default' && matrix.chain-type || '' }}
test_nethermind_mox_block_scout_web:
strategy:
fail-fast: false
Expand Down Expand Up @@ -725,4 +747,4 @@ jobs:
ACCOUNT_ENABLED: "true"
ACCOUNT_REDIS_URL: "redis://localhost:6379"
SOURCIFY_INTEGRATION_ENABLED: "true"
CHAIN_TYPE: "${{ matrix.chain-type }}"
CHAIN_TYPE: ${{ matrix.chain-type != 'default' && matrix.chain-type || '' }}
3 changes: 2 additions & 1 deletion PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
- [ ] If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
- [ ] I checked whether I should update the docs and did so by submitting a PR to https://github.com/blockscout/docs
- [ ] If I added/changed/removed ENV var, I submitted a PR to https://github.com/blockscout/docs to update the list of env vars at https://github.com/blockscout/docs/blob/master/for-developers/information-and-settings/env-variables.md and I updated the version to `master` in the Version column. Changes will be reflected in this table: https://docs.blockscout.com/for-developers/information-and-settings/env-variables.
- [ ] If I add new indices into DB, I checked, that they are not redundant with PGHero or other tools
- [ ] If I added new DB indices, I checked, that they are not redundant with PGHero or other tools.
- [ ] If I added/removed chain type, I modified the Github CI matrix and PR labels accordingly.

0 comments on commit 92ac44c

Please sign in to comment.