Update CICD #476
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: tests | |
on: | |
push: | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
set_network: | |
runs-on: self-hosted | |
outputs: | |
auction: ${{ steps.auction.outputs.auction }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Helm | |
uses: azure/[email protected] | |
with: | |
version: v3.10.0 | |
- uses: azure/setup-kubectl@v3 | |
with: | |
version: 'v1.29.0' | |
- name: Set up test namespace | |
run: | | |
echo "$CONFIG" | base64 -d > /tmp/config | |
export KUBECONFIG=/tmp/config | |
kubectl kustomize kubernetes/test --enable-helm | kubectl apply -f - | |
kubectl wait deployment -n test-casperholders mynctl --for condition=Available=True --timeout=120s | |
env: | |
CONFIG: ${{ secrets.KUBE_CONFIG }} | |
- name: Setup network | |
run: ./.github/data/setupNetwork.sh https://nctl.test.casperholders.io | |
env: | |
FAKE_KEY: ${{ secrets.VUE_APP_FAKE_KEY }} | |
- name: Store output | |
id: auction | |
run: | | |
echo $VITE_APP_AUCTION_MANAGER_HASH | |
echo "auction=$VITE_APP_AUCTION_MANAGER_HASH" >> $GITHUB_OUTPUT | |
build: | |
runs-on: self-hosted | |
needs: set_network | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Test auction hash | |
run: echo ${{needs.set_network.outputs.auction}} | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
version: 9 | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Code style | |
run: pnpm lint | |
- name: Build | |
run: pnpm vite build --mode e2e --config vite.e2e.config.js | |
env: | |
VITE_APP_FAKE_KEY: ${{ secrets.VUE_APP_FAKE_KEY }} | |
VITE_APP_FAKE_VALIDATOR_KEY: ${{ secrets.VUE_APP_FAKE_VALIDATOR_KEY }} | |
VITE_APP_FAKE_MULTISIG_KEY: ${{ secrets.VUE_APP_FAKE_MULTISIG_KEY }} | |
VITE_APP_FAKE_SECOND_MULTISIG_KEY: ${{ secrets.VUE_APP_FAKE_SECOND_MULTISIG_KEY }} | |
VITE_APP_AUCTION_MANAGER_HASH: ${{needs.set_network.outputs.auction}} | |
VITE_APP_E2E: true | |
VITE_COVERAGE: true | |
NODE_OPTIONS: --max-old-space-size=8192 | |
- name: Save build folder | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
if-no-files-found: error | |
path: dist | |
retention-days: 1 | |
e2e: | |
runs-on: self-hosted | |
container: cypress/browsers:latest | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
containers: [ 1, 2, 3, 4 ] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download the build | |
uses: actions/download-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
version: 9 | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- uses: actions/cache@v4 | |
name: Setup cypress cache | |
with: | |
path: | | |
~/.cache/Cypress | |
key: cypress-cache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml','*/pnpm-lock.yaml') }} | |
restore-keys: | | |
cypress-cache-${{ runner.os }}- | |
- name: Install cypress | |
run: ./node_modules/.bin/cypress install --force | |
- name: Cypress run | |
uses: cypress-io/github-action@v6 | |
with: | |
install: false | |
command: pnpm cy2 run --parallel --browser chrome --record --key test --ci-build-id test | |
start: pnpm vite preview --port 8080 | |
wait-on: http://localhost:8080 | |
wait-on-timeout: 240 | |
env: | |
CYPRESS_API_URL: https://director.test.casperholders.io/ | |
NODE_OPTIONS: --max-old-space-size=8192 | |
- uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: cypress-screenshots | |
path: cypress/screenshots | |
- name: Rename coverage file | |
run: mv coverage/coverage-final.json coverage/coverage-final-${{ matrix.containers }}.json | |
- name: Archive code coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: code-coverage-report-${{ matrix.containers }} | |
path: coverage | |
coverage: | |
needs: e2e | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
- uses: pnpm/action-setup@v4 | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
version: 9 | |
run_install: false | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
cache: 'pnpm' | |
- name: Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Merge coverage | |
run: | | |
mkdir multiple-coverage | |
cp code-coverage-report-*/coverage-final-*.json multiple-coverage | |
pnpm nyc merge multiple-coverage merged-output/merged-coverage.json | |
pnpm nyc report -t merged-output --report-dir coverage --reporter=json --reporter=lcov --reporter=clover --reporter=json-summary | |
- uses: codecov/codecov-action@v4 | |
- name: SonarCloud Scan | |
uses: sonarsource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
cleanup: | |
needs: e2e | |
if: ${{ always() }} | |
runs-on: self-hosted | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Helm | |
uses: azure/[email protected] | |
with: | |
version: v3.10.0 | |
- uses: azure/setup-kubectl@v3 | |
with: | |
version: 'v1.29.0' | |
- name: Delete test namespace | |
if: ${{ always() }} | |
run: | | |
echo "$CONFIG" | base64 -d > /tmp/config | |
export KUBECONFIG=/tmp/config | |
kubectl kustomize kubernetes/test --enable-helm | kubectl delete -f - | |
env: | |
CONFIG: ${{ secrets.KUBE_CONFIG }} | |