Skip to content

CI

CI #4683

Workflow file for this run

name: CI
on:
push:
branches:
- develop
- master
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
- master
schedule:
- cron: '0 0 * * *'
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
prepare:
name: Check how tests should be executed
runs-on: ubuntu-20.04
if: false
outputs:
uuid: ${{ steps.uuid.outputs.value }}
commit-message: ${{ steps.commit-message.outputs.value }}
is-label-present: ${{ steps.label-present.outputs.value }}
cypress: ${{ steps.cypress.outputs.value }}
synpress: ${{ steps.synpress.outputs.value }}
steps:
- name: ⬇️ ・Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: '50'
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- name: Generate unique ID 💎
id: uuid
run: |
echo "value=sha-$GITHUB_SHA-time-$(date +"%s")" >> $GITHUB_OUTPUT
echo "sha-$GITHUB_SHA-time-$(date +"%s")"
- name: Get Commit Message
id: commit-message
run: |
MSG=$(git log --format=%B -n 1 ${{github.event.after}})
echo "value=$(printf "$MSG" | xargs)" >> $GITHUB_OUTPUT
- name: Echo commit message
run: echo "${{ steps.commit-message.outputs.value }}"
- uses: docker://agilepathway/pull-request-label-checker:latest
id: check-if-cypress-tests-should-run
continue-on-error: true
with:
one_of: ready-for-tests,QA
repo_token: ${{ secrets.GITHUB_TOKEN }}
- uses: docker://agilepathway/pull-request-label-checker:latest
id: check-if-synpress-tests-should-run
continue-on-error: true
with:
one_of: ready-for-synpress-tests,QA
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check if cypress label is present
if: steps.check-if-cypress-tests-should-run.outcome == 'success'
id: cypress-label-present
run: |
echo "Label present"
echo "value=true" >> $GITHUB_OUTPUT
- name: Check if synpress label is present
if: steps.check-if-synpress-tests-should-run.outcome == 'success'
id: synpress-label-present
run: |
echo "Label present"
echo "value=true" >> $GITHUB_OUTPUT
- name: Check if cypress tests should be executed
id: cypress
if: ${{ ((github.event_name == 'push') || ((steps.cypress-label-present.outputs.value == 'true')&& !(github.actor == 'dependabot[bot]'))) }}
run: |
echo "Cypress tests should be executed"
echo "value=true" >> $GITHUB_OUTPUT
- name: Check if synpress tests should be executed
id: synpress
if: ${{ contains(steps.commit-message.outputs.value,'trigger-synpress') || github.event_name == 'push' || (steps.synpress-label-present.outputs.value == 'true') }}
run: |
echo "Synpress tests should be executed"
echo "value=true" >> $GITHUB_OUTPUT
install:
name: Install
runs-on: ubuntu-20.04
steps:
- name: ⬇️ ・Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: '50'
- name: ⎔・Setup node
uses: actions/setup-node@v3
with:
node-version: lts/hydrogen
check-latest: true
cache: 'yarn'
- name: Install dependencies
run: yarn install --immutable
env:
HUSKY: '0'
- name: Generate open-api
run: yarn codegen:socket
- name: Generate graphql
run: yarn codegen:graphql
- name: Compress workspace artifact
run: tar --create --use-compress-program='zstd -T0' --file=/tmp/workspace.tar.zst .
- name: Upload workspace artifact
uses: actions/upload-artifact@v3
with:
name: workspace
path: /tmp/workspace.tar.zst
retention-days: 3
lint:
name: 🔬 ・Lint
needs: install
runs-on: ubuntu-20.04
steps:
- name: 📥 ・Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Run linter
run: yarn lint --quiet
test:
name: 🔎 ・Test
needs: install
runs-on: ubuntu-20.04
steps:
- name: 📥 ・Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Run tests
run: yarn test
typecheck:
name: ⬡・Typecheck
needs: install
runs-on: ubuntu-20.04
steps:
- name: 📥 ・Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Run typescript check
run: yarn typecheck
build:
name: ⚙️ ・Build
needs: install
runs-on: ubuntu-20.04
steps:
- name: 📥 Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Build app
env:
REACT_APP_ETHERSCAN_API_KEY: ${{ secrets.REACT_APP_ETHERSCAN_API_KEY }}
run: yarn ipfs-build
- name: Compress build artifact
run: tar --create --use-compress-program='zstd -T0' --file=/tmp/build.tar.zst build
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: build
path: /tmp/build.tar.zst
retention-days: 3
synpress:
name: 👘 ・Synpress
runs-on: ubuntu-22.04
needs: prepare
if: ${{ needs.prepare.outputs.synpress }}
env:
PRIVATE_KEY: ${{ secrets.TEST_WALLET_PRIVATE_KEY }}
strategy:
fail-fast: false
matrix:
containers: [02transactionfull, 01transactionless]
steps:
- name: Setup chrome version
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable
- name: ⬇️ ・Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: '50'
- name: Set synpress default params
run: |
echo "TEST_PARAMS=-s 'tests/synpress/specs/${{ matrix.containers }}/*/*.ts'" >> "$GITHUB_ENV"
- name: Check if synpress should be reported to dashboard
if: ${{ (github.event_name == 'push') || !(contains(needs.prepare.outputs.commit-message,'skip-synpress-dashboard')) }}
run: |
echo "TEST_PARAMS=-s 'tests/synpress/specs/${{ matrix.containers }}/*/*.ts --record --key=${{ secrets.CYPRESS_DASHBOARD_KEY }} --tag SYNPRESS'" >> "$GITHUB_ENV"
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: '16'
check-latest: true
cache: 'yarn'
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Install dependencies
run: yarn install --immutable
- name: Generate open-api
run: yarn codegen:socket
- name: Codegen socket
run: yarn codegen:socket
- name: Codegen GraphQl
run: yarn codegen:graphql
- name: Run synpress tests
run: |
sudo -E ./start-tests.sh
continue-on-error: true
env:
CI: true
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
COMMIT_INFO_SHA: ${{ needs.prepare.outputs.uuid }}
TEST_PARAMS: ${{ env.TEST_PARAMS }}
PRIVATE_KEY: ${{ secrets.TEST_WALLET_PRIVATE_KEY }}
SLOW_MODE: true
DISPLAY: ':99'
CYPRESS_RESOURCES_WAIT: true
- name: Save code coverage results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.containers }}
path: |
docker/videos-ci
cypress:
name: 🎡 ・Cypress (${{ matrix.containers }})
needs: prepare
runs-on: ubuntu-20.04
if: ${{ needs.prepare.outputs.cypress }}
strategy:
fail-fast: false
matrix:
containers: [Container01, Container02, Container03, Container04]
steps:
- name: ⬇️ ・Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: '50'
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: '16'
check-latest: true
cache: 'yarn'
- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Install dependencies
run: yarn install --immutable
- name: Generate open-api
run: yarn codegen:socket
- name: Codegen socket
run: yarn codegen:socket
- name: Codegen GraphQl
run: yarn codegen:graphql
- name: Install dependencies
run: yarn install --immutable
- name: Verify Cypress
run: yarn cypress install
- name: Run cypress tests
if: ${{ !(github.event_name == 'push') }}
run: yarn cypress:ci 'yarn cypress run -r mochawesome --record --group electron --key=${{ secrets.CYPRESS_DASHBOARD_KEY }} --parallel --tag TESTS_FROM_PR --ci-build-id=${{ needs.prepare.outputs.uuid }}'
continue-on-error: true
env:
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{ needs.prepare.outputs.uuid }}
- name: Run cypress tests after merge
if: ${{ (github.event_name == 'push') }}
run: yarn cypress:ci './node_modules/.bin/cypress run -r mochawesome --record --group electron --key=${{ secrets.CYPRESS_DASHBOARD_KEY }} --parallel }} --tag SMOKE_TESTS --ci-build-id=${{ needs.prepare.outputs.uuid }}'
continue-on-error: true
env:
COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
COMMIT_INFO_SHA: ${{ needs.prepare.outputs.uuid }}
- name: Merge test results into one
run: |
yarn run report:merge
mv index.json ${{ matrix.containers }}.json
continue-on-error: true
- name: Save code coverage results
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.containers }}
path: |
${{ matrix.containers }}.json
tests/screenshots
cypress-report:
name: ⬡・Merge and generate cypress reports
needs: [install, cypress, synpress]
runs-on: ubuntu-20.04
steps:
- name: 📥 ・Download workspace artifact
uses: actions/download-artifact@v3
with:
name: workspace
- name: Extract workspace artifact
run: tar --extract --use-compress-program='zstd -d' --file=workspace.tar.zst
- uses: actions/download-artifact@v3
with:
name: Container01
path: mochawesome-report
- uses: actions/download-artifact@v3
with:
name: Container02
path: mochawesome-report
- uses: actions/download-artifact@v3
with:
name: Container03
path: mochawesome-report
- uses: actions/download-artifact@v3
with:
name: Container04
path: mochawesome-report
- uses: actions/download-artifact@v3
continue-on-error: true
with:
name: 01transactionless
path: mochawesome-report
- uses: actions/download-artifact@v3
continue-on-error: true
with:
name: 02transactionfull
path: mochawesome-report
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Merge test results into one
run: yarn run report:merge
- name: Generate HTML report
run: yarn run report:generate
- name: Save code coverage results
uses: actions/upload-artifact@v3
with:
name: test-report
path: |
public-report
mochawesome-report/public-report/screenshots/**
mochawesome-report/public-report/videos/**
retention-days: 3
- name: Delete merged artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: |
Container01
Container02
Container03
Container04
depcleanup:
name: 🧹 Dependabot Cleanup
if: github.actor == 'dependabot[bot]'
needs: [install, lint, test, typecheck, build]
runs-on: ubuntu-20.04
steps:
- name: Delete workspace artifact
uses: geekyeggo/delete-artifact@v2
with:
name: workspace
cleanup:
name: 🧹 Cleanup
if: ${{ success() && github.actor != 'dependabot[bot]' }}
needs: [install, lint, test, typecheck, build]
runs-on: ubuntu-20.04
steps:
- name: Delete workspace artifact
uses: geekyeggo/delete-artifact@v2
with:
name: workspace