0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

CI: Prefer per-job cache rather than artifact I/O (#3781)

* chore(ci): prefer per-job cache rather than artifact io

* chore: update cache step

* chore: fix cache key

* chore(ci): build on windows as well

* chore(ci): enable remote cache

* chore: run build on all three platforms

* chore: prefer turbo to custom caching logic

* chore: build AFTER install

* chore: build on node 14

* chore: remove build, parallelize tasks

* chore: update cache

* chore: prime build caches

* chore: fix indentation

* chore(ci): only build on ubuntu

* chore(ci): changelog needs build

* chore(ci): ignore updates to md files

* chore(ci): add 20 min timeout for e2e tests

* chore(ci): enable FORCE_COLOR

* chore: run turbo with `--output-logs=new-only`

Co-authored-by: Nate Moore <nate@astro.build>
This commit is contained in:
Nate Moore 2022-06-30 17:26:37 -04:00 committed by GitHub
parent d07ad8a782
commit f9290b328a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 76 deletions

View file

@ -1,11 +0,0 @@
cd artifacts
mkdir -p ../tmp/packages
mv * ../tmp/packages
cd ../tmp
tar -cvzpf artifacts.tar.gz *
mv artifacts.tar.gz ../artifacts.tar.gz
cd ..
tar -xvzpf artifacts.tar.gz
rm -rf artifacts
rm -rf tmp
rm -f artifacts.tar.gz

View file

@ -7,6 +7,7 @@ on:
pull_request: pull_request:
paths-ignore: paths-ignore:
- '.vscode/**' - '.vscode/**'
- '**/*.md'
# Automatically cancel in-progress actions on the same branch # Automatically cancel in-progress actions on the same branch
concurrency: concurrency:
@ -17,8 +18,14 @@ defaults:
run: run:
shell: bash shell: bash
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_REMOTE_ONLY: true
FORCE_COLOR: true
ASTRO_TELEMETRY_DISABLED: true
jobs: jobs:
# Lint can run in parallel with Build.
lint: lint:
name: Lint name: Lint
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -65,13 +72,17 @@ jobs:
# Checks that the formatter runs successfully on all files # Checks that the formatter runs successfully on all files
# In the future, we may have this fail PRs on unformatted code # In the future, we may have this fail PRs on unformatted code
- name: Format Check - name: Format Check
run: yarn format --list run: pnpm run format --list
# Build installs all devDependencies and runs our full build pipeline. # Build primes out build caches for Turbo
# We upload all `dist/` artifacts to GitHub, which can be shared by all dependent jobs.
build: build:
name: Build Packages name: 'Build: ${{ matrix.os }}'
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node_version: [14]
fail-fast: true
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -79,10 +90,10 @@ jobs:
- name: Setup PNPM - name: Setup PNPM
uses: pnpm/action-setup@v2.2.1 uses: pnpm/action-setup@v2.2.1
- name: Setup Node - name: Setup node@${{ matrix.node_version }}
uses: actions/setup-node@v3 uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: ${{ matrix.node_version }}
cache: 'pnpm' cache: 'pnpm'
- name: Install dependencies - name: Install dependencies
@ -91,23 +102,10 @@ jobs:
- name: Build Packages - name: Build Packages
run: pnpm run build run: pnpm run build
- name: Upload Package Artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
packages/*/dist/**
packages/*/*/dist/**
packages/webapi/mod.js
packages/webapi/mod.js.map
if-no-files-found: error
# Test depends on Build's output, which allows us to skip any build process!
test: test:
name: 'Test: ${{ matrix.os }} (node@${{ matrix.node_version }})' name: 'Test: ${{ matrix.os }} (node@${{ matrix.node_version }})'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: needs: build
ASTRO_TELEMETRY_DISABLED: true
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest] os: [ubuntu-latest]
@ -118,8 +116,6 @@ jobs:
- os: macos-latest - os: macos-latest
node_version: 14 node_version: 14
fail-fast: false fail-fast: false
needs:
- build
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -138,30 +134,25 @@ jobs:
with: with:
deno-version: v1.19.3 deno-version: v1.19.3
- name: Download Build Artifacts
uses: actions/download-artifact@v3
- name: Extract Artifacts
run: ./.github/extract-artifacts.sh
- name: Install dependencies - name: Install dependencies
run: pnpm install run: pnpm install
- name: Build Packages
run: pnpm run build
- name: Test - name: Test
run: pnpm run test run: pnpm run test
e2e: e2e:
name: 'Test (E2E): ${{ matrix.os }} (node@${{ matrix.node_version }})' name: 'Test (E2E): ${{ matrix.os }} (node@${{ matrix.node_version }})'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
env: timeout-minutes: 20
ASTRO_TELEMETRY_DISABLED: true needs: build
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, windows-latest] os: [ubuntu-latest, windows-latest]
node_version: [14] node_version: [14]
fail-fast: false fail-fast: false
needs:
- build
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -175,27 +166,23 @@ jobs:
node-version: ${{ matrix.node_version }} node-version: ${{ matrix.node_version }}
cache: 'pnpm' cache: 'pnpm'
- name: Download Build Artifacts
uses: actions/download-artifact@v3
- name: Extract Artifacts
run: ./.github/extract-artifacts.sh
- name: Install dependencies - name: Install dependencies
run: pnpm install run: pnpm install
- name: Build Packages
run: pnpm run build
- name: Test - name: Test
run: pnpm run test:e2e run: pnpm run test:e2e
smoke: smoke:
name: 'Test (Smoke): ${{ matrix.os }} (node@${{ matrix.node_version }})' name: 'Test (Smoke): ${{ matrix.os }} (node@${{ matrix.node_version }})'
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: build
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, windows-latest] os: [ubuntu-latest, windows-latest]
node_version: [14] node_version: [14]
needs:
- build
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
@ -214,26 +201,20 @@ jobs:
node-version: ${{ matrix.node_version }} node-version: ${{ matrix.node_version }}
cache: 'pnpm' cache: 'pnpm'
- name: Download Build Artifacts
uses: actions/download-artifact@v3
- name: Extract Artifacts
run: ./.github/extract-artifacts.sh
- name: Install dependencies - name: Install dependencies
run: pnpm install --no-frozen-lockfile run: pnpm install --no-frozen-lockfile
- name: Build Packages
run: pnpm run build
- name: Test - name: Test
run: pnpm run test:smoke run: pnpm run test:smoke
# Changelog can only run _after_ build.
# We download all `dist/` artifacts from GitHub to skip the build process.
changelog: changelog:
name: Changelog PR or Release name: Changelog PR or Release
if: ${{ (github.ref_name == 'main' || github.head_ref == 'next') && github.repository_owner == 'withastro' }} if: ${{ (github.ref_name == 'main' || github.head_ref == 'next') && github.repository_owner == 'withastro' }}
needs: [build]
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -246,15 +227,12 @@ jobs:
node-version: 16 node-version: 16
cache: 'pnpm' cache: 'pnpm'
- name: Download Build Artifacts
uses: actions/download-artifact@v3
- name: Extract Artifacts
run: ./.github/extract-artifacts.sh
- name: Install dependencies - name: Install dependencies
run: pnpm install run: pnpm install
- name: Build Packages
run: pnpm run build
- name: Create Release Pull Request or Publish - name: Create Release Pull Request or Publish
id: changesets id: changesets
uses: changesets/action@v1 uses: changesets/action@v1

View file

@ -9,19 +9,19 @@
"scripts": { "scripts": {
"postinstall": "patch-package", "postinstall": "patch-package",
"release": "pnpm run build && changeset publish", "release": "pnpm run build && changeset publish",
"build": "turbo run build --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"", "build": "turbo run build --output-logs=new-only --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
"build:ci": "turbo run build:ci --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"", "build:ci": "turbo run build:ci --output-logs=new-only --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
"build:examples": "turbo run build --scope=\"@example/*\"", "build:examples": "turbo run build --scope=\"@example/*\"",
"dev": "turbo run dev --no-deps --no-cache --parallel --scope=astro --scope=create-astro --scope=\"@astrojs/*\"", "dev": "turbo run dev --no-deps --no-cache --parallel --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
"format": "pnpm run format:code", "format": "pnpm run format:code",
"format:ci": "pnpm run format:imports && pnpm run format:code", "format:ci": "pnpm run format:imports && pnpm run format:code",
"format:code": "prettier -w . --cache", "format:code": "prettier -w . --cache",
"format:imports": "organize-imports-cli ./packages/*/tsconfig.json ./packages/*/*/tsconfig.json", "format:imports": "organize-imports-cli ./packages/*/tsconfig.json ./packages/*/*/tsconfig.json",
"test": "turbo run test --concurrency=1", "test": "turbo run test --output-logs=new-only --concurrency=1",
"test:match": "cd packages/astro && pnpm run test:match", "test:match": "cd packages/astro && pnpm run test:match",
"test:templates": "turbo run test --filter=create-astro --concurrency=1", "test:templates": "turbo run test --filter=create-astro --concurrency=1",
"test:smoke": "node scripts/smoke/index.js", "test:smoke": "node scripts/smoke/index.js",
"test:vite-ci": "turbo run test --no-deps --scope=astro --concurrency=1", "test:vite-ci": "turbo run test --output-logs=new-only --no-deps --scope=astro --concurrency=1",
"test:e2e": "cd packages/astro && pnpm playwright install && pnpm run test:e2e", "test:e2e": "cd packages/astro && pnpm playwright install && pnpm run test:e2e",
"test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match", "test:e2e:match": "cd packages/astro && pnpm playwright install && pnpm run test:e2e:match",
"benchmark": "turbo run benchmark --scope=astro", "benchmark": "turbo run benchmark --scope=astro",

View file

@ -1,13 +1,14 @@
{ {
"$schema": "https://turborepo.org/schema.json",
"baseBranch": "origin/main", "baseBranch": "origin/main",
"pipeline": { "pipeline": {
"build": { "build": {
"dependsOn": ["^build"], "dependsOn": ["^build"],
"outputs": ["**/dist/**", "!**/vendor/**"] "outputs": ["dist/**/*", "!vendor/**", "mod.js", "mod.js.map"]
}, },
"build:ci": { "build:ci": {
"dependsOn": ["^build:ci"], "dependsOn": ["^build:ci"],
"outputs": ["**/dist/**", "!**/vendor/**"] "outputs": ["dist/**/*", "!vendor/**", "mod.js", "mod.js.map"]
}, },
"dev": { "dev": {
"cache": false "cache": false