refactor: chain name selection #3498
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Lint, build and test | |
on: [push] | |
jobs: | |
linting: | |
name: eslint, stylelint | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
# common steps | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm ci | |
# job specific steps | |
- name: Run ESlint | |
run: npm run eslint | |
- name: Run Stylelint | |
run: npm run stylelint | |
- name: Hadolint for linting Dockerfile | |
uses: hadolint/[email protected] | |
with: | |
dockerfile: ./Dockerfile | |
config: ./.hadolint.yaml | |
jestSetup: | |
name: 'Set up jest chunks' | |
runs-on: ubuntu-latest | |
outputs: | |
test-chunks: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} | |
test-chunk-ids: ${{ steps['set-test-chunk-ids'].outputs['test-chunk-ids'] }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: npm ci | |
- id: set-test-chunks | |
name: Set Chunks | |
run: echo "test-chunks=$(npx jest --listTests --json | jq -cM '[_nwise(length / 5 | ceil)]')" >> $GITHUB_OUTPUT | |
- id: set-test-chunk-ids | |
name: Set Chunk IDs | |
run: echo "test-chunk-ids=$(echo $CHUNKS | jq -cM 'to_entries | map(.key)')" >> $GITHUB_OUTPUT | |
env: | |
CHUNKS: ${{ steps['set-test-chunks'].outputs['test-chunks'] }} | |
jest: | |
name: Jest Tests (chunk ${{ matrix.chunk }}) | |
runs-on: ubuntu-latest | |
needs: | |
- jestSetup | |
strategy: | |
fail-fast: false | |
matrix: | |
node-version: [18.x] | |
chunk: ${{ fromJson(needs.jestSetup.outputs['test-chunk-ids']) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm ci | |
- name: Start Streamr Docker Stack | |
uses: streamr-dev/[email protected] | |
with: | |
services-to-start: "cassandra mysql nginx entry-point broker-node-storage-1 broker-node-no-storage-1 broker-node-no-storage-2 dev-chain-fast postgres-fastchain" | |
- name: Run Jest Tests | |
run: echo $CHUNKS | jq '.[${{ matrix.chunk }}] | .[] | @text' | xargs npx jest --verbose --useStderr --forceExit --coverage=false --logHeapUsage --runInBand | |
env: | |
CHUNKS: ${{ needs.jestSetup.outputs['test-chunks'] }} | |
TEST_HOOKS: 1 | |
cypress: | |
# It takes time and often fails. @todo make it more reliable, then re-enable. | |
if: ${{ false }} | |
name: Cypress Tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x] | |
steps: | |
# common steps | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: | | |
npm ci | |
- name: Cache node modules | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Cache Cypress binary | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/Cypress | |
key: cypress-${{ runner.os }}-cypress-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
cypress-${{ runner.os }}-cypress- | |
# job specific steps | |
- name: Build app | |
run: npm run build | |
- name: Start Streamr Docker Stack | |
uses: streamr-dev/[email protected] | |
with: | |
services-to-start: "mysql cassandra parity-node0 parity-sidechain-node0 broker-node-storage-1-brubeck nginx" | |
- name: Run Cypress tests | |
uses: cypress-io/github-action@v6 | |
with: | |
browser: chrome | |
# Start serving 'dist' folder from previous build step | |
start: npx serve dist --listen 3333 --single | |
wait-on: "http://localhost" | |
wait-on-timeout: 120 | |
- uses: actions/upload-artifact@master | |
with: | |
name: screenshots | |
path: | |
cypress/screenshots |