Skip to content

Build/v2 signals

Build/v2 signals #9

Workflow file for this run

# Build and test everything
#
# First it builds the packages and stores them in artifacts.
# Meanwhile it lints the code.
# Then it runs the unit tests with the artifacts, as well as builds the docs and insights
# Once it all works, it does a release
name: Qwik CI
# TODO fix e2e tests hanging and not cancelling
# # We only need one instance of the workflow running at a time, per branch
# concurrency:
# group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
# cancel-in-progress: true
on:
pull_request:
push:
branches:
- main
- next
- qwik-labs
- vercelserverless
- 'build/**'
workflow_dispatch:
inputs:
disttag:
description: 'Publish "@builder.io/qwik" to NPM using this dist-tag, push the git-tag to the repo and create a GitHub release. The "latest" and "next" dist-tags will use the version number already committed in package.json.'
required: true
type: choice
default: 'dev'
options:
- dev
- next
- latest
env:
# Disable incremental build, speeds up CI
CARGO_INCREMENTAL: 0
jobs:
changes:
name: Setup
runs-on: ubuntu-latest
outputs:
hash-qwik: ${{ steps.cache-qwik.outputs.cache-primary-key }}
hash-rust: ${{ steps.cache-rust.outputs.cache-primary-key }}
hash-others: ${{ steps.cache-others.outputs.cache-primary-key }}
hash-docs: ${{ steps.cache-docs.outputs.cache-primary-key }}
hash-insights: ${{ steps.cache-insights.outputs.cache-primary-key }}
build-qwik: ${{ steps.cache-qwik.outputs.cache-hit != 'true' }}
build-rust: ${{ steps.cache-rust.outputs.cache-hit != 'true' }}
build-others: ${{ steps.cache-others.outputs.cache-hit != 'true' }}
build-docs: ${{ steps.cache-docs.outputs.cache-hit != 'true' }}
# TEMP v2: disable insights build
# build-insights: ${{ steps.cache-insights.outputs.cache-hit != 'true' }}
build-insights: false
steps:
- name: Branch
run: echo "${{ github.ref }}"
- name: NPM Dist Tag
run: echo "${{ github.event.inputs.disttag }}"
- name: Github event
run: echo event_name=${{ github.event_name }}
- name: Checkout
uses: actions/checkout@v4
- name: 'cache: qwik'
id: cache-qwik
uses: actions/cache/restore@v4
with:
lookup-only: true
path: packages/qwik/dist
key: ${{ hashfiles('pnpm-lock.yaml', 'packages/qwik/**/*') }}
- name: 'cache: rust'
id: cache-rust
uses: actions/cache/restore@v4
with:
lookup-only: true
path: packages/qwik/dist/bindings
key: ${{ hashfiles('rust-toolchain', '**/Cargo.toml', '**/Cargo.lock', '**/*.rs') }}
- name: 'cache: others'
id: cache-others
uses: actions/cache/restore@v4
with:
lookup-only: true
path: |
packages/qwik-city/lib
packages/qwik-labs/lib
packages/qwik-labs/vite
packages/qwik-react/lib
packages/qwik-react/vite
packages/eslint-plugin-qwik/dist
packages/create-qwik/dist
# note that all inputs need to be listed here, including qwik, for correct cache invalidation
key: ${{ hashfiles('pnpm-lock.yaml', 'packages/qwik/**/*', 'rust-toolchain', '**/Cargo.toml', '**/Cargo.lock', '**/*.rs', 'packages/qwik-city/**/*', 'packages/qwik-labs/**/*', 'packages/qwik-react/**/*', 'packages/eslint-plugin-qwik/**/*', 'packages/create-qwik/**/*') }}
- name: 'cache: docs'
id: cache-docs
uses: actions/cache/restore@v4
with:
lookup-only: true
path: |
packages/docs/dist
packages/docs/server
key: ${{ hashfiles('pnpm-lock.yaml', 'packages/qwik/**/*', 'rust-toolchain', '**/Cargo.toml', '**/Cargo.lock', '**/*.rs', 'packages/qwik-city/**/*', 'packages/qwik-labs/**/*', 'packages/qwik-react/**/*', 'packages/qwik-docs/**/*') }}
- name: 'cache: insights'
id: cache-insights
uses: actions/cache/restore@v4
with:
path: cache-insights
key: ${{ hashfiles('pnpm-lock.yaml', 'packages/qwik/**/*', 'rust-toolchain', '**/Cargo.toml', '**/Cargo.lock', '**/*.rs', 'packages/qwik-city/**/*', 'packages/qwik-labs/**/*', 'packages/qwik-insights/**/*') }}
############ BUILD Qwik ############
build-qwik:
if: needs.changes.outputs.build-qwik == 'true'
name: Build Qwik
needs: changes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Install NPM Dependencies
run: |
corepack enable
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- name: 'build: qwik'
run: pnpm build --qwik --set-dist-tag="${{ github.event.inputs.disttag }}"
- name: Print Qwik Dist Build
run: tree packages/qwik/dist/
- name: Save cache
uses: actions/cache/save@v4
with:
path: packages/qwik/dist/
key: ${{ needs.changes.outputs.hash-qwik }}
- name: Save artifacts
uses: actions/upload-artifact@v4
with:
name: dist-qwik-no-optimizer
path: packages/qwik/dist/
if-no-files-found: error
combined-qwik:
name: Bundle Qwik
if: always() && (needs.build-qwik.result == 'success' || needs.build-qwik.result == 'skipped') && (needs.build-rust.result == 'success' || needs.build-rust.result == 'skipped') && (needs.build-bindings.result == 'success' || needs.build-bindings.result == 'skipped')
runs-on: ubuntu-latest
needs:
- build-qwik
- build-rust
- build-bindings
- changes
steps:
- name: Restore artifacts
uses: actions/download-artifact@v4
- name: Restore Qwik from cache
if: needs.changes.outputs.build-qwik != 'true'
uses: actions/cache/restore@v4
with:
path: packages/qwik/dist/
key: ${{ needs.changes.outputs.hash-qwik }}
- name: Move Qwik artifact
if: needs.changes.outputs.build-qwik == 'true'
run: |
mkdir -p packages/qwik/dist/
mv dist-qwik-no-optimizer/* packages/qwik/dist/
- name: Restore Rust from cache
if: needs.changes.outputs.build-rust != 'true'
uses: actions/cache/restore@v4
with:
path: packages/qwik/dist/bindings
key: ${{ needs.changes.outputs.hash-rust }}
- name: Move Rust Artifacts
if: needs.changes.outputs.build-rust == 'true'
run: |
mkdir -p packages/qwik/dist/bindings
mv dist-bindings-*/* packages/qwik/dist/bindings
- name: Save Rust to cache
if: needs.changes.outputs.build-rust == 'true'
uses: actions/cache/save@v4
with:
path: packages/qwik/dist/bindings
key: ${{ needs.changes.outputs.hash-rust }}
- name: Upload Qwik artifact
uses: actions/upload-artifact@v4
with:
name: dist-qwik
path: packages/qwik/dist/
if-no-files-found: error
############ BUILD PACKAGE ############
build-package:
name: Build Other Packages
needs:
- changes
- combined-qwik
if: always() && needs.combined-qwik.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Checkout
if: needs.changes.outputs.build-others == 'true'
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
if: needs.changes.outputs.build-others == 'true'
- name: Setup Node
if: needs.changes.outputs.build-others == 'true'
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Restore Qwik artifact
uses: actions/download-artifact@v4
with:
name: dist-qwik
path: packages/qwik/dist/
- name: Install NPM Dependencies
if: needs.changes.outputs.build-others == 'true'
run: corepack pnpm install
- name: 'build: qwik-city & others'
if: needs.changes.outputs.build-others == 'true'
run: pnpm build --tsc --api --qwikcity --cli --qwiklabs --qwikreact --eslint --set-dist-tag="${{ github.event.inputs.disttag }}"
- name: 'restore: qwik-city & others'
if: needs.changes.outputs.build-others != 'true'
uses: actions/cache/restore@v4
with:
path: |
packages/qwik-city/lib
packages/qwik-labs/lib
packages/qwik-labs/vite
packages/qwik-react/lib
packages/qwik-react/vite
packages/eslint-plugin-qwik/dist
packages/create-qwik/dist
key: ${{ needs.changes.outputs.hash-others }}
- name: Print QwikCity Lib Build
run: tree packages/qwik-city/lib/
- name: Upload QwikCity Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dist-qwikcity
path: packages/qwik-city/lib/
if-no-files-found: error
- name: Print QwikLabs Lib Build
run: tree packages/qwik-labs/lib/ packages/qwik-labs/vite/
- name: Upload QwikLabs+React Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dist-qwiklabs
path: |
packages/qwik-labs/lib/
packages/qwik-labs/vite/
packages/qwik-labs/package.json
if-no-files-found: error
- name: Print qwik-react Lib Build
run: tree packages/qwik-react/lib/ packages/qwik-react/vite/
- name: Upload qwik-react Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dist-qwikreact
path: |
packages/qwik-react/lib/
packages/qwik-react/vite/
packages/qwik-react/package.json
if-no-files-found: error
- name: Print Create Qwik CLI Dist Build
run: tree packages/create-qwik/dist/
- name: Upload Create Qwik CLI Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dist-create-qwik
path: packages/create-qwik/dist/
if-no-files-found: error
- name: Print Eslint rules Dist Build
run: tree packages/eslint-plugin-qwik/dist/
- name: Upload Eslint rules Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dist-eslint-plugin-qwik
path: packages/eslint-plugin-qwik/dist/
if-no-files-found: error
- name: 'save cache: others'
id: cache-others
if: needs.changes.outputs.build-others == 'true'
uses: actions/cache/save@v4
with:
key: ${{ needs.changes.outputs.hash-others }}
path: |
packages/qwik-city/lib
packages/qwik-labs/lib
packages/qwik-labs/vite
packages/qwik-react/lib
packages/qwik-react/vite
packages/eslint-plugin-qwik/dist
packages/create-qwik/dist
############ BUILD RUST ############
build-rust:
if: needs.changes.outputs.build-rust == 'true'
name: Build optimizer x86 Linux + wasm
needs: changes
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
# additionally install wasm32-unknown-unknown target
target: wasm32-unknown-unknown
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
# This installs everything + the latest wasm-pack binary
- run: pnpm install wasm-pack
- name: Build x86 Platform Binding
run: pnpm build --platform-binding
- name: Build wasm Platform Binding
run: pnpm build --wasm
- name: Print Packages Dist Build
continue-on-error: true
run: ls -lR packages/qwik/dist/bindings/
- name: Upload Platform Binding Artifact
uses: actions/upload-artifact@v4
with:
name: dist-bindings-wasm
path: packages/qwik/dist/bindings/*
if-no-files-found: error
############ BUILD PLATFORM BINDINGS ############
build-bindings:
if: needs.changes.outputs.build-rust == 'true'
strategy:
matrix:
settings:
# the last x86 macos available as a standard runner
- host: macos-13
target: x86_64-apple-darwin
- host: macos-latest
target: aarch64-apple-darwin
- host: windows-latest
target: x86_64-pc-windows-msvc
name: Build optimizer ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
needs: changes
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: pnpm install
- name: Build Platform Binding
run: pnpm build --platform-binding
- name: Print Packages Dist Build
continue-on-error: true
run: ls -lR packages/qwik/dist/bindings/
- name: Upload Platform Binding Artifact
uses: actions/upload-artifact@v4
with:
name: dist-bindings-${{ matrix.settings.target }}
path: packages/qwik/dist/bindings/*.node
if-no-files-found: error
############ BUILD INSIGHTS ############
build-insights:
# it seems that skipped grandparents cause the children to be skipped as well
if: always() && needs.changes.outputs.build-insights == 'true' && needs.build-package.result == 'success'
name: Build Insights
needs:
- changes
- build-package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Download Build Artifacts
uses: actions/download-artifact@v4
- name: Move Distribution Artifacts
run: |
mkdir -p packages/qwik/dist/
mv dist-qwik/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv dist-qwikcity/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
mv dist-qwiklabs/lib packages/qwik-labs/lib
mv dist-qwiklabs/vite packages/qwik-labs/vite
- run: corepack pnpm install --frozen-lockfile
- name: Build Qwik Insights
run: pnpm run build.packages.insights
############ BUILD DOCS ############
build-docs:
if: always() && needs.changes.outputs.build-docs == 'true' && needs.build-package.result == 'success'
name: Build Docs
needs:
- changes
- build-package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Download Build Artifacts
uses: actions/download-artifact@v4
- name: Move Distribution Artifacts
run: |
mkdir -p packages/qwik/dist/
mv dist-qwik/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv dist-qwikcity/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
mv dist-qwiklabs/lib packages/qwik-labs/lib
mv dist-qwiklabs/vite packages/qwik-labs/vite
mv dist-qwikreact/lib packages/qwik-react/lib
mv dist-qwikreact/vite packages/qwik-react/vite
- run: corepack pnpm install --frozen-lockfile
- name: Build Qwik Docs
run: pnpm run build.packages.docs
- name: Cloudflare Pages Deployment
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: 'qwik-docs'
directory: packages/docs/dist
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
############ RELEASE ############
release:
name: Release
runs-on: ubuntu-latest
needs:
- test-e2e
- changes
# TEMP v2: disable release
if: false
#if: always() && (needs.changes.outputs.build-qwik == 'true' || needs.changes.outputs.build-others == 'true' || needs.changes.outputs.build-rust == 'true') && needs.test-e2e.result == 'success'
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Download Build Artifacts
uses: actions/download-artifact@v4
- name: Move Distribution Artifacts
run: |
mkdir -p packages/qwik/dist/
mv dist-qwik/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv dist-qwikcity/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
mv dist-qwiklabs/lib packages/qwik-labs/lib
mv dist-qwiklabs/vite packages/qwik-labs/vite
mv dist-qwikreact/lib packages/qwik-react/lib
mv dist-qwikreact/vite packages/qwik-react/vite
- run: pnpm install --frozen-lockfile
- name: Commit Build Artifacts
if: github.event_name == 'push'
env:
QWIK_API_TOKEN_GITHUB: ${{ secrets.QWIK_API_TOKEN_GITHUB }}
run: pnpm run qwik-save-artifacts
- name: Dry-Run Publish
if: github.event_name != 'workflow_dispatch'
run: pnpm build --set-dist-tag="${{ github.event.inputs.disttag }}" --validate --release --dry-run
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Publish
if: github.event_name == 'workflow_dispatch'
run: pnpm build --set-dist-tag="${{ github.event.inputs.disttag }}" --validate --release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
############ E2E TEST ############
test-e2e:
# Sometimes the tests just hang
timeout-minutes: 10
name: E2E Tests
if: always() && (needs.changes.outputs.build-qwik == 'true' || needs.changes.outputs.build-others == 'true' || needs.changes.outputs.build-rust == 'true') && needs.build-package.result == 'success' && needs.test-unit.result == 'success'
needs:
- build-package
- changes
- test-unit
strategy:
matrix:
settings:
- host: ubuntu-latest
browser: chromium
- host: macos-latest
browser: webkit
runs-on: ${{ matrix.settings.host }}
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Download Build Artifacts
uses: actions/download-artifact@v4
- name: Move Distribution Artifacts
run: |
mkdir -p packages/qwik/dist/
mv dist-qwik/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv dist-qwikcity/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
- run: pnpm install --frozen-lockfile
- name: Install Playwright
run: npx playwright install ${{ matrix.settings.browser }} --with-deps
- name: Playwright E2E Tests
run: pnpm run test.e2e.${{ matrix.settings.browser }} --timeout 60000 --retries 3 --workers 1
- name: Validate Create Qwik Cli
run: pnpm cli.validate
############ UNIT TEST ############
test-unit:
name: Unit Tests
if: always() && (needs.changes.outputs.build-qwik == 'true' || needs.changes.outputs.build-others == 'true' || needs.changes.outputs.build-rust == 'true') && needs.build-package.result == 'success'
runs-on: ubuntu-latest
needs:
- changes
- build-package
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Download Build Artifacts
uses: actions/download-artifact@v4
- name: Move Distribution Artifacts
run: |
mkdir -p packages/qwik/dist/
mv dist-qwik/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv dist-qwikcity/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
- run: pnpm install --frozen-lockfile
- name: Unit Tests
run: pnpm run test.unit
########### VALIDATE RUST ############
validate-rust:
if: needs.changes.outputs.build-rust == 'true'
name: Validate Rust
runs-on: ubuntu-latest
needs: changes
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Format check
run: cargo fmt --check
- name: Build check
run: cargo check --all-features
- name: Clippy check
run: cargo clippy --all-features
- name: Unit tests
run: make test
########### LINT PACKAGE ############
lint-package:
name: Lint Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- run: pnpm install --frozen-lockfile
- name: Prettier Check
if: always()
run: pnpm run lint.prettier
- name: Build ESLint
if: always()
run: pnpm tsm scripts/index.ts --eslint
- name: ESLint Check
if: always()
run: pnpm run lint.eslint
############ TRIGGER QWIKCITY E2E TEST ############
trigger-qwikcity-e2e:
name: Trigger Qwik City E2E
runs-on: ubuntu-latest
needs:
- changes
- release
if: always() && (needs.changes.outputs.build-qwik == 'true' || needs.changes.outputs.build-rust == 'true' || needs.changes.outputs.build-others == 'true') && needs.release.result == 'success' && github.ref_name == 'main'
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.QWIK_API_TOKEN_GITHUB }}
repository: builderIO/qwik-city-e2e
event-type: main-updated