Skip to content

ci: added ability to publish test packages #14701

ci: added ability to publish test packages

ci: added ability to publish test packages #14701

Workflow file for this run

name: Qwik CI
on:
pull_request:
push:
branches:
- main
- next
- qwik-labs
- vercelserverless
- 'build/**'
workflow_dispatch:
inputs:
node_version:
description: 'Node version to use for the build'
required: false
type: string
default: '20.x'
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:
fullbuild: ${{ steps.filter.outputs.fullbuild == 'true' || github.event.inputs.disttag != '' }}
insightsbuild: ${{ steps.filter_insights.outputs.insightsbuild == 'true' || github.event.inputs.disttag != '' }}
docsbuild: ${{ steps.filter_docs.outputs.docsbuild == 'true' || github.event.inputs.disttag != '' }}
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
if: github.event_name == 'pull_request'
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Branch
run: echo "${{ github.ref }}"
- name: NPM Dist Tag
run: echo "${{ github.event.inputs.disttag }}"
- uses: actions/[email protected]
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
fullbuild:
- 'packages/qwik/src/**/*.ts'
- 'packages/qwik/src/**/*.tsx'
- 'packages/qwik/src/**/*.rs'
- 'packages/qwik-city/**/*.ts'
- 'packages/qwik-city/**/*.tsx'
- 'packages/qwik-labs/package.json'
- 'packages/qwik-labs/src/**/*.ts'
- 'packages/qwik-labs/src/**/*.tsx'
- 'packages/qwik-labs/src-vite/**/*.ts'
- 'packages/eslint-plugin-qwik/**/*.ts'
- 'starters/apps/**/*.ts'
- 'starters/apps/**/*.tsx'
- 'starters/e2e/**/*.ts'
- 'tsconfig.json'
- 'pnpm-lock.yaml'
- 'Cargo.yaml'
- '.github/workflows/*.yaml'
- 'scripts/*.ts'
- uses: dorny/paths-filter@v2
id: filter_insights
with:
filters: |
insightsbuild:
- 'packages/insights/**/*'
- uses: dorny/paths-filter@v2
id: filter_docs
with:
filters: |
docsbuild:
- 'packages/docs/**/*'
- name: Print variables output
run: |
echo fullbuild=${{ steps.filter.outputs.fullbuild }}
echo insightsbuild=${{ steps.filter_insights.outputs.insightsbuild }}
echo docsbuild=${{ steps.filter_docs.outputs.docsbuild }}
echo disttag=${{ github.event.inputs.disttag }}
echo event_name=${{ github.event_name }}
############ BUILD PACKAGE ############
build-package:
name: Build Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Install NPM Dependencies
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- name: Build Packages
run: pnpm tsm scripts/index.ts --tsc --build --cli --api --qwiklabs --qwikcity --eslint --platform-binding-wasm-copy --set-dist-tag="${{ github.event.inputs.disttag }}"
- name: Print Qwik Dist Build
run: tree packages/qwik/dist/
- name: Upload Qwik Build Artifacts
uses: actions/[email protected]
with:
name: dist-dev-builder-io-qwik
path: packages/qwik/dist/
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/[email protected]
with:
name: dist-dev-create-qwik
path: packages/create-qwik/dist/
if-no-files-found: error
- name: Build Eslint rules
run: pnpm tsm scripts/index.ts --eslint
- name: Print Eslint rules Dist Build
run: tree packages/eslint-plugin-qwik/dist/
- name: Upload Eslint rules Build Artifacts
uses: actions/[email protected]
with:
name: dist-dev-eslint-plugin-qwik
path: packages/eslint-plugin-qwik/dist/
if-no-files-found: error
# - run: pnpm dlx [email protected] publish --compact --pnpm ./packages/qwik/dist ./packages/qwik-city/lib ./packages/eslint-plugin-qwik/dist ./packages/create-qwik/dist
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
############ BUILD WASM #############
build-wasm:
name: Build WASM
runs-on: ubuntu-latest
needs: changes
steps:
- name: Print fullbuild output
run: echo ${{ needs.changes.outputs.fullbuild }}
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: corepack enable
- name: Install Rust toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
# additionally install wasm32-unknown-unknown target
target: wasm32-unknown-unknown
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- uses: jetli/[email protected]
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
with:
version: 'v0.10.3'
- name: Build WASM
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm tsm scripts/index.ts --wasm --set-dist-tag="${{ github.event.inputs.disttag }}"
- name: Print WASM Dist Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
continue-on-error: true
run: tree packages/qwik/dist/bindings/
- name: Upload WASM Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
name: dist-bindings-wasm
path: packages/qwik/dist/bindings/*
if-no-files-found: error
- name: Build Platform Binding
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm tsm scripts/index.ts --platform-binding
shell: bash
- name: Print Packages Dist Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
continue-on-error: true
run: tree packages/qwik/dist/
- name: Upload Platform Binding Artifact
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
name: dist-bindings-x86_64-unknown-linux-gnu
path: packages/qwik/dist/bindings/*.node
if-no-files-found: error
############ BUILD PLATFORM BINDINGS ############
build-bindings:
strategy:
matrix:
settings:
# looks like that's the last intel macos
- 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 ${{ matrix.settings.target }}
runs-on: ${{ matrix.settings.host }}
needs: changes
steps:
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: corepack enable
- name: Install Rust toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Pull Latest Image
if: ${{ needs.changes.outputs.fullbuild == 'true' && matrix.settings.docker }}
run: ${{ matrix.settings.docker }}
env:
DOCKER_REGISTRY_URL: ghcr.io
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' && matrix.settings.setup }}
run: ${{ matrix.settings.setup }}
shell: bash
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- name: Build Platform Binding
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm tsm scripts/index.ts --platform-binding
shell: bash
- name: Print Packages Dist Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
continue-on-error: true
run: ls -lR packages/qwik/dist/
- name: Upload Platform Binding Artifact
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
name: dist-bindings-${{ matrix.settings.target }}
path: packages/qwik/dist/bindings/*.node
if-no-files-found: error
############ BUILD INSIGHTS ############
build-insights:
name: Build Insights
needs: changes
runs-on: ubuntu-latest
steps:
- name: Checkout
if: ${{ needs.changes.outputs.insightsbuild == 'true' }}
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
if: ${{ needs.changes.outputs.insightsbuild == 'true' }}
- name: Setup Node
if: ${{ needs.changes.outputs.insightsbuild == 'true' }}
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.insightsbuild == 'true' }}
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- name: Build Qwik Insights
if: ${{ needs.changes.outputs.insightsbuild == 'true' }}
run: pnpm run build.packages.insights
############ BUILD DOCS ############
build-docs:
name: Build Docs
needs: changes
if: ${{ needs.changes.outputs.docsbuild == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- name: Install Rust toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install NPM Dependencies
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
# Temporary fix for the docs build, soon we will use caching
- run: pnpm build.local
- run: pnpm build --platform-binding
- name: Build Qwik Docs
run: pnpm -C packages/docs build
############ BUILD DISTRIBUTION ############
build-distribution:
name: Build Distribution
runs-on: ubuntu-latest
needs:
- build-package
- build-wasm
- build-bindings
- test-unit
- validate-rust
- changes
steps:
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Setup Node
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- name: Download Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
- name: Print Distribution Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree dist-dev-builder-io-qwik/
- name: Move Distribution Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: mv dist-dev-builder-io-qwik/* packages/qwik/dist/
- name: Print Bindings Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree dist-bindings-*/
- name: Move Binding Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: mv dist-bindings-*/* packages/qwik/dist/bindings/
- name: Print Packages Dist Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree packages/qwik/dist/
- name: Upload Qwik Distribution Artifact
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
name: builderio-qwik-distribution
path: packages/qwik/dist/*
if-no-files-found: error
- name: Build QwikCity / QwikLabs
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm tsm scripts/index.ts --tsc --qwikcity --qwiklabs --api --eslint
- name: Print QwikCity Lib Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree packages/qwik-city/lib/
- name: Upload QwikCity Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
name: builderio-qwikcity-distribution
path: packages/qwik-city/lib/
if-no-files-found: error
- name: Print QwikLabs Lib Build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: tree packages/qwik-labs/lib/ packages/qwik-labs/vite/
- name: Upload QwikLabs Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
name: builderio-qwiklabs-distribution
path: |
packages/qwik-labs/lib/
packages/qwik-labs/vite/
packages/qwik-labs/package.json
if-no-files-found: error
############ RELEASE ############
release:
name: Release
runs-on: ubuntu-latest
needs:
- build-distribution
- test-e2e
- changes
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
steps:
- name: Checkout
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Download Build Artifacts
uses: actions/[email protected]
- name: Print Distribution Artifacts
run: tree builderio-qwik-distribution/
- name: Print Create Qwik CLI Artifacts
run: tree dist-dev-create-qwik/
- name: Move Distribution Artifacts
run: |
mkdir -p packages/qwik/dist/
mv builderio-qwik-distribution/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv builderio-qwikcity-distribution/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-dev-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-dev-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
mv builderio-qwiklabs-distribution/lib packages/qwik-labs/lib
mv builderio-qwiklabs-distribution/vite packages/qwik-labs/vite
- name: Install NPM Dependencies
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- name: Commit Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' && 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 tsm scripts/index.ts --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 tsm scripts/index.ts --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:
name: E2E Tests
needs:
- build-distribution
- changes
strategy:
matrix:
settings:
- host: ubuntu-latest
browser: chromium
node: 20.x
- host: macos-latest
browser: webkit
node: 20.x
runs-on: ${{ matrix.settings.host }}
steps:
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
- name: Setup Node ${{ matrix.settings.node }}
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
with:
node-version: ${{ matrix.settings.node }}
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: corepack enable
shell: bash
- name: Download Build Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
- name: Move Distribution Artifacts
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: |
mkdir -p packages/qwik/dist/
mv builderio-qwik-distribution/* packages/qwik/dist/
mkdir -p packages/qwik-city/lib/
mv builderio-qwikcity-distribution/* packages/qwik-city/lib/
mkdir -p packages/create-qwik/dist/
mv dist-dev-create-qwik/* packages/create-qwik/dist/
mkdir -p packages/eslint-plugin-qwik/dist/
mv dist-dev-eslint-plugin-qwik/* packages/eslint-plugin-qwik/dist/
- name: Install NPM Dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- name: Install Playwright
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: npx playwright install ${{ matrix.settings.browser }} --with-deps
- name: Playwright E2E Tests
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm run test.e2e.${{ matrix.settings.browser }} --timeout 60000 --retries 3 --workers 1
- name: Validate Create Qwik Cli
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
run: pnpm cli.validate
############ UNIT TEST ############
test-unit:
name: Unit Tests
runs-on: ubuntu-latest
needs:
- changes
steps:
- name: Checkout
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Install NPM Dependencies
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
pnpm install --frozen-lockfile
- name: Build core
run: pnpm run build.core
- name: Unit Tests
run: pnpm run test.unit
########### VALIDATE RUST ############
validate-rust:
name: Validate Rust
runs-on: ubuntu-latest
needs: changes
steps:
- name: Checkout
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/[email protected]
- name: Install Rust toolchain
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/toolchain@v1
with:
profile: minimal
components: rustfmt, clippy
- name: Cache cargo dependencies
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: cargo-deps-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Cache cargo build
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions/cache@v4
with:
path: target
key: cargo-build-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
- name: Format check
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/cargo@v1
with:
command: fmt
args: -- --check
- name: Build check
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/cargo@v1
with:
command: check
args: --all-features
- name: Clippy check
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-features
- name: Unit tests
if: ${{ needs.changes.outputs.fullbuild == 'true' }}
uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
########### LINT PACKAGE ############
lint-package:
name: Lint Package
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/[email protected]
with:
node-version: 20.x
cache: 'pnpm'
registry-url: https://registry.npmjs.org/
- run: corepack enable
- name: Install NPM Dependencies
run: |
# Ensure that the qwik binary gets made
mkdir -p packages/qwik/dist/bindings/
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:
- release
if: ${{ needs.changes.outputs.fullbuild == 'true' && 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