speed up ci #728
Workflow file for this run
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: Continuous Integration | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
security-audit: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
cache: "npm" | |
- name: Install dependencies | |
run: npm ci | |
- name: Install Snyk | |
uses: snyk/actions/setup@3e2680e8df93a24b52d119b1305fb7cedc60ceae # latest master (no released tag) | |
- name: Snyk VULN and License Check Test | |
run: snyk test --all-projects --sarif-file-output=snyk.sarif | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
- name: Report known vulnerabilities | |
run: npm audit | |
- name: Upload SARIF result to GitHub Code Scanning | |
uses: github/codeql-action/upload-sarif@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5 | |
if: always() | |
with: | |
sarif_file: snyk.sarif | |
test-with-node: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org/ | |
cache: "npm" | |
- name: Install dependencies | |
run: npm ci | |
- name: Build all workspace packages | |
run: npm run build | |
- name: Run linter for all packages | |
run: npm run lint --ws | |
- name: Run dwn-server (background) | |
run: | | |
node node_modules/@web5/dwn-server/dist/esm/src/main.js & | |
echo "DWN_SERVER_BACKGROUND_PROCESS=$!" >> $GITHUB_ENV | |
- name: Run tests for all packages | |
run: npm run test:node --ws -- --color | |
env: | |
TEST_DWN_URL: http://localhost:3000 | |
- name: Terminate dwn-server | |
run: kill $DWN_SERVER_BACKGROUND_PROCESS || true | |
- name: Upload test coverage to Codecov | |
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
test-with-browsers: | |
name: test-with-browsers (${{ matrix.browser }}) | |
# Run browser tests using macOS so that WebKit tests don't fail under a Linux environment | |
runs-on: macos-latest | |
strategy: | |
matrix: | |
browser: ['--group chromium', ' --group firefox', '--group webkit'] | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org/ | |
cache: "npm" | |
- name: Install dependencies | |
run: npm ci | |
- name: Get Playwright Version (for cache) | |
id: get-playwright-version | |
run: | | |
PLAYWRIGHT_VERSION=$(npm view @playwright/test version) | |
echo "Playwright Version: $PLAYWRIGHT_VERSION" | |
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV | |
- name: Restore Cached Playwright Browsers | |
id: cache-playwright-restore | |
uses: actions/cache/restore@v3 | |
with: | |
path: ~/Library/Caches/ms-playwright | |
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} | |
- name: Install Playwright Browsers (if no cache) | |
if: steps.cache-playwright-restore.outputs.cache-hit != 'true' | |
run: npx playwright install --with-deps | |
- name: Save Playwright Cache (if no cache) | |
uses: actions/cache/save@v3 | |
id: cache-playwright-save | |
if: steps.cache-playwright-restore.outputs.cache-hit != 'true' | |
with: | |
path: ~/Library/Caches/ms-playwright | |
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} | |
- name: Build esm | |
run: npm run build:esm --ws | |
- name: Build browser bundles | |
run: npm run build:browser --ws | |
- name: Run dwn-server (background) | |
run: | | |
node node_modules/@web5/dwn-server/dist/esm/src/main.js & | |
echo "DWN_SERVER_BACKGROUND_PROCESS=$!" >> $GITHUB_ENV | |
- name: Run tests for matrix ${{ matrix.browser }} | |
run: npm run test:browser --ws -- ${{ matrix.browser }} | |
- name: Terminate dwn-server | |
run: kill $DWN_SERVER_BACKGROUND_PROCESS || true | |
web5-spec: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- uses: TBD54566975/[email protected] |