mirror of
https://github.com/zen-browser/www.git
synced 2025-07-08 17:30:01 +02:00
ci(cache): improve ci cache in ci pipeline
This commit is contained in:
parent
7d5f44d29a
commit
fd1ee76377
2 changed files with 172 additions and 125 deletions
295
.github/workflows/ci-pipeline.yml
vendored
295
.github/workflows/ci-pipeline.yml
vendored
|
@ -1,155 +1,149 @@
|
||||||
name: CI Pipeline
|
name: CI Pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ci-pipeline-${{ github.head_ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check_changes:
|
||||||
|
name: Check Changes
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
outputs:
|
||||||
|
exists: ${{ steps.filter.outputs.exists }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Filter changes
|
||||||
|
uses: dorny/paths-filter@v3
|
||||||
|
id: filter
|
||||||
|
with:
|
||||||
|
filters: |
|
||||||
|
exists:
|
||||||
|
- '**'
|
||||||
|
- '!**.md'
|
||||||
|
- '!.gitignore'
|
||||||
|
- '!.gitattributes'
|
||||||
|
- '!.vscode/**'
|
||||||
|
- '!.env.example'
|
||||||
|
- '!README.md'
|
||||||
|
- '!CONTRIBUTING.md'
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
|
name: Setup
|
||||||
|
needs: check_changes
|
||||||
|
if: ${{ needs.check_changes.outputs.exists == 'true' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
- name: Restore Turborepo cache
|
||||||
node-version: lts/*
|
id: turbo-cache
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10.11.0
|
|
||||||
- name: Cache node_modules
|
|
||||||
id: cache-deps
|
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: .turbo
|
||||||
.turbo
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-turbo-
|
${{ runner.os }}-turbo-
|
||||||
- name: Verify pnpm installation
|
lookup-only: true
|
||||||
run: pnpm --version
|
|
||||||
|
- name: Restore node_modules cache
|
||||||
|
id: node-modules-cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
node_modules
|
||||||
|
*/node_modules
|
||||||
|
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-modules-
|
||||||
|
lookup-only: true
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
if: steps.node-modules-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: lts/*
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
if: steps.node-modules-cache.outputs.cache-hit != 'true'
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10.11.0
|
||||||
|
run_install: false
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
if: steps.node-modules-cache.outputs.cache-hit != 'true'
|
||||||
run: pnpm install --frozen-lockfile
|
run: pnpm install --frozen-lockfile
|
||||||
|
|
||||||
eslint:
|
parallel-jobs:
|
||||||
|
needs: [check_changes, setup]
|
||||||
|
if: ${{ needs.check_changes.outputs.exists == 'true' }}
|
||||||
|
name: ${{ matrix.job }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
job: [ESLint, Prettier, CSpell, Vitest, Build]
|
||||||
|
fail-fast: false
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: setup
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
- name: Restore Turborepo cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: .turbo
|
||||||
|
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-turbo-
|
||||||
|
|
||||||
|
- name: Restore node_modules cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
node_modules
|
||||||
|
*/node_modules
|
||||||
|
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-modules-
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 22
|
node-version: lts/*
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
with:
|
with:
|
||||||
version: 10.11.0
|
version: 10.11.0
|
||||||
- name: Restore node_modules from cache
|
run_install: false
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
- name: Run ESLint
|
||||||
path: |
|
if: matrix.job == 'ESLint'
|
||||||
.turbo
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-turbo-
|
|
||||||
- name: Run Eslint check
|
|
||||||
run: pnpm exec turbo run lint
|
run: pnpm exec turbo run lint
|
||||||
|
|
||||||
prettier:
|
- name: Run Prettier
|
||||||
runs-on: ubuntu-latest
|
if: matrix.job == 'Prettier'
|
||||||
needs: setup
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: lts/*
|
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10.11.0
|
|
||||||
- name: Restore node_modules from cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
.turbo
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-turbo-
|
|
||||||
- name: Run Prettier check
|
|
||||||
run: pnpm exec turbo run format
|
run: pnpm exec turbo run format
|
||||||
|
|
||||||
cspell:
|
- name: Run CSpell
|
||||||
runs-on: ubuntu-latest
|
if: matrix.job == 'CSpell'
|
||||||
needs: setup
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: lts/*
|
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10.11.0
|
|
||||||
- name: Restore node_modules from cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
.turbo
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-turbo-
|
|
||||||
- name: Run cspell check
|
|
||||||
run: pnpm exec turbo run spell
|
run: pnpm exec turbo run spell
|
||||||
|
|
||||||
vitest:
|
- name: Run Vitest
|
||||||
runs-on: ubuntu-latest
|
if: matrix.job == 'Vitest'
|
||||||
needs: setup
|
run: pnpm exec turbo run test
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: lts/*
|
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10.11.0
|
|
||||||
- name: Restore node_modules from cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
.turbo
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-turbo-
|
|
||||||
- name: Run Vitest tests
|
|
||||||
run: pnpm exec turbo test
|
|
||||||
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: setup
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: lts/*
|
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10.11.0
|
|
||||||
- name: Restore node_modules from cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
.turbo
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
|
||||||
restore-keys: |
|
|
||||||
${{ runner.os }}-turbo-
|
|
||||||
- name: Build project
|
- name: Build project
|
||||||
|
if: matrix.job == 'Build'
|
||||||
run: pnpm exec turbo run build
|
run: pnpm exec turbo run build
|
||||||
|
|
||||||
- name: Upload build output
|
- name: Upload build output
|
||||||
|
if: matrix.job == 'Build'
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build
|
name: build
|
||||||
|
@ -157,33 +151,84 @@ jobs:
|
||||||
dist
|
dist
|
||||||
|
|
||||||
playwright:
|
playwright:
|
||||||
|
name: Playwright Tests
|
||||||
|
needs: [check_changes, parallel-jobs]
|
||||||
|
if: ${{ needs.check_changes.outputs.exists == 'true' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- uses: actions/setup-node@v4
|
|
||||||
with:
|
- name: Restore Turborepo cache
|
||||||
node-version: lts/*
|
|
||||||
- uses: pnpm/action-setup@v4
|
|
||||||
with:
|
|
||||||
version: 10.11.0
|
|
||||||
- name: Restore node_modules from cache
|
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
with:
|
with:
|
||||||
path: |
|
path: .turbo
|
||||||
.turbo
|
|
||||||
node_modules
|
|
||||||
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
key: ${{ runner.os }}-turbo-${{ github.sha }}
|
||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-turbo-
|
${{ runner.os }}-turbo-
|
||||||
|
|
||||||
|
- name: Restore node_modules cache
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
node_modules
|
||||||
|
*/node_modules
|
||||||
|
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-node-modules-
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: lts/*
|
||||||
|
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 10.11.0
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Cache Playwright browsers
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ~/.cache/ms-playwright
|
||||||
|
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-playwright-
|
||||||
|
|
||||||
- name: Install Playwright Browsers
|
- name: Install Playwright Browsers
|
||||||
run: pnpm exec playwright install --with-deps
|
run: pnpm exec playwright install --with-deps
|
||||||
|
|
||||||
- name: Download build output
|
- name: Download build output
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: build
|
name: build
|
||||||
path: dist
|
path: dist
|
||||||
|
|
||||||
- name: Run Playwright tests
|
- name: Run Playwright tests
|
||||||
run: pnpm exec turbo run test:playwright
|
run: pnpm exec turbo run test:playwright
|
||||||
|
|
||||||
|
verify:
|
||||||
|
name: Verify
|
||||||
|
needs: [check_changes, parallel-jobs, playwright]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: always()
|
||||||
|
outputs:
|
||||||
|
success: ${{ steps.set-result.outputs.success }}
|
||||||
|
steps:
|
||||||
|
- name: Set Result
|
||||||
|
id: set-result
|
||||||
|
run: |
|
||||||
|
# Check if changes exist but no jobs ran, or if any job failed or was cancelled
|
||||||
|
if [[ "${{ needs.check_changes.outputs.exists }}" != "true" ]]; then
|
||||||
|
echo "success=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "No relevant changes detected - pipeline passed"
|
||||||
|
elif [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
|
||||||
|
echo "success=false" >> $GITHUB_OUTPUT
|
||||||
|
echo "Pipeline failed - some jobs failed or were cancelled"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "success=true" >> $GITHUB_OUTPUT
|
||||||
|
echo "All jobs completed successfully"
|
||||||
|
fi
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"createdDefault",
|
"createdDefault",
|
||||||
"createdDesc",
|
"createdDesc",
|
||||||
"daniel",
|
"daniel",
|
||||||
|
"dorny",
|
||||||
"FMPEG",
|
"FMPEG",
|
||||||
"ferrocyante",
|
"ferrocyante",
|
||||||
"flatpaks",
|
"flatpaks",
|
||||||
|
@ -52,6 +53,7 @@
|
||||||
"Pdzly",
|
"Pdzly",
|
||||||
"Ribaric",
|
"Ribaric",
|
||||||
"taroj",
|
"taroj",
|
||||||
|
"Turborepo",
|
||||||
"testid",
|
"testid",
|
||||||
"theming",
|
"theming",
|
||||||
"tuta",
|
"tuta",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue