Merge pull request #39 from bitsocialnet/fix/ci-kubo-flake #86
This file contains hidden or 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
| # CI for src folder | |
| name: CI | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - '**' | |
| paths: | |
| - 'test/**' | |
| - 'src/**' | |
| - 'scripts/**' | |
| - 'config/**' | |
| - '.github/**' | |
| - '.yarnrc.yml' | |
| - 'package.json' | |
| - 'yarn.lock' | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - 'test/**' | |
| - 'src/**' | |
| - 'scripts/**' | |
| - 'config/**' | |
| - '.github/**' | |
| - '.yarnrc.yml' | |
| - 'package.json' | |
| - 'yarn.lock' | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| checks: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - run: corepack enable | |
| - run: yarn install --immutable --mode=skip-build | |
| - run: yarn lint | |
| - run: yarn type-check | |
| - name: Run unit tests with coverage | |
| id: run_unit_tests | |
| run: yarn test:coverage | |
| - name: Print failed unit tests | |
| if: ${{ failure() && steps.run_unit_tests.outcome == 'failure' }} | |
| run: node .github/workflows/print-vitest-failures.cjs | |
| - name: Write coverage badge payload | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| run: node scripts/write-coverage-badge.mjs | |
| - name: Upload coverage badge artifact | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-badge | |
| path: badges/coverage.json | |
| - run: yarn build | |
| - name: Upload dist artifact | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| e2e: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 20 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - suite: mock | |
| command: CHROME_BIN=$(which chromium-browser) yarn test:e2e:mock | |
| browsers: chromium | |
| - suite: chrome | |
| command: DEBUG="plebbit-js:*,bitsocial-react-hooks:*" CHROME_BIN=$(which chromium-browser) yarn test:e2e:chrome | |
| browsers: chromium | |
| - suite: firefox | |
| command: DEBUG="plebbit-js:*,bitsocial-react-hooks:*" FIREFOX_BIN=$(which firefox) yarn test:e2e:firefox | |
| browsers: firefox | |
| - suite: mock-content | |
| command: CHROME_BIN=$(which chromium-browser) yarn test:e2e:mock-content | |
| browsers: chromium | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - run: corepack enable | |
| - run: yarn install --immutable | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/ms-playwright | |
| key: playwright-${{ runner.os }}-${{ hashFiles('yarn.lock') }} | |
| - run: sudo echo "255.255.255.255 cloudflare-ipfs.com" | sudo tee -a /etc/hosts | |
| - run: sudo echo "255.255.255.255 pubsubprovider.xyz" | sudo tee -a /etc/hosts | |
| - run: yarn playwright install ${{ matrix.browsers }} | |
| - run: yarn build | |
| - run: yarn test:server & yarn test:server:wait-on | |
| - name: Run e2e ${{ matrix.suite }} tests | |
| id: run_e2e | |
| run: ${{ matrix.command }} | |
| - name: Print failed e2e ${{ matrix.suite }} tests | |
| if: ${{ failure() && steps.run_e2e.outcome == 'failure' }} | |
| run: node .github/workflows/print-vitest-failures.cjs | |
| dist: | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 5 | |
| needs: [checks, e2e] | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref_name }} | |
| - name: Download dist artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist | |
| path: dist/ | |
| - name: Download coverage badge artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: coverage-badge | |
| path: badges/ | |
| - run: git add dist badges/coverage.json --force | |
| - run: git status | |
| - uses: stefanzweifel/git-auto-commit-action@v4 | |
| with: | |
| commit_message: 'chore(ci): update dist and coverage badge' | |
| file_pattern: 'dist badges/coverage.json' | |
| add_options: '--force' | |
| branch: ${{ github.ref_name }} |