263 lines
6.9 KiB
YAML
263 lines
6.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
paths-ignore:
|
|
- '.vscode/**'
|
|
- '**/*.md'
|
|
|
|
# Automatically cancel in-progress actions on the same branch
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request_target' && github.head_ref || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
env:
|
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
|
FORCE_COLOR: true
|
|
ASTRO_TELEMETRY_DISABLED: true
|
|
|
|
jobs:
|
|
lint:
|
|
name: Lint
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out repository
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup PNPM
|
|
uses: pnpm/action-setup@v2.2.1
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 16
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Status
|
|
run: git status
|
|
|
|
# Lint autofix cannot run on forks, so just skip those! See https://github.com/wearerequired/lint-action/issues/13
|
|
- name: Lint (External)
|
|
if: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != github.repository_owner }}
|
|
run: pnpm run lint
|
|
|
|
# Otherwise, run lint autofixer
|
|
- name: Lint
|
|
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login == github.repository_owner }}
|
|
uses: wearerequired/lint-action@v1.11.1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
eslint: true
|
|
prettier: false
|
|
auto_fix: true
|
|
git_name: github-actions[bot]
|
|
git_email: github-actions[bot]@users.noreply.github.com
|
|
commit_message: 'chore(lint): ${linter} fix'
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
neutral_check_on_warning: true
|
|
|
|
# Checks that the formatter runs successfully on all files
|
|
# In the future, we may have this fail PRs on unformatted code
|
|
- name: Format Check
|
|
run: pnpm run format --list
|
|
|
|
# Build primes out build caches for Turbo
|
|
build:
|
|
name: 'Build: ${{ matrix.os }}'
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
node_version: [14]
|
|
fail-fast: true
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup PNPM
|
|
uses: pnpm/action-setup@v2.2.1
|
|
|
|
- name: Setup node@${{ matrix.node_version }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ matrix.node_version }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Build Packages
|
|
run: pnpm run build
|
|
|
|
test:
|
|
name: 'Test: ${{ matrix.os }} (node@${{ matrix.node_version }})'
|
|
runs-on: ${{ matrix.os }}
|
|
needs: build
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
node_version: [14, 16]
|
|
include:
|
|
- os: windows-latest
|
|
node_version: 14
|
|
- os: macos-latest
|
|
node_version: 14
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup PNPM
|
|
uses: pnpm/action-setup@v2.2.1
|
|
|
|
- name: Setup node@${{ matrix.node_version }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ matrix.node_version }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Use Deno
|
|
uses: denoland/setup-deno@v1
|
|
with:
|
|
deno-version: v1.19.3
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Build Packages
|
|
run: pnpm run build
|
|
|
|
- name: Test
|
|
run: pnpm run test
|
|
|
|
e2e:
|
|
name: 'Test (E2E): ${{ matrix.os }} (node@${{ matrix.node_version }})'
|
|
runs-on: ${{ matrix.os }}
|
|
timeout-minutes: 20
|
|
needs: build
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest, windows-latest]
|
|
node_version: [14]
|
|
fail-fast: false
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup PNPM
|
|
uses: pnpm/action-setup@v2.2.1
|
|
|
|
- name: Setup node@${{ matrix.node_version }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ matrix.node_version }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Build Packages
|
|
run: pnpm run build
|
|
|
|
- name: Test
|
|
run: pnpm run test:e2e
|
|
|
|
smoke:
|
|
name: 'Test (Smoke): ${{ matrix.os }} (node@${{ matrix.node_version }})'
|
|
runs-on: ${{ matrix.os }}
|
|
needs: build
|
|
strategy:
|
|
matrix:
|
|
os: [ubuntu-latest]
|
|
node_version: [14]
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup PNPM
|
|
uses: pnpm/action-setup@v2.2.1
|
|
|
|
- name: Setup node@${{ matrix.node_version }}
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: ${{ matrix.node_version }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Checkout docs
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: withastro/docs
|
|
path: smoke/docs
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --no-frozen-lockfile
|
|
|
|
- name: Build Packages
|
|
run: pnpm run build
|
|
|
|
- name: Test
|
|
run: pnpm run test:smoke
|
|
|
|
changelog:
|
|
name: Changelog PR or Release
|
|
if: ${{ (github.ref_name == 'main' || github.head_ref == 'next') && github.repository_owner == 'withastro' }}
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Setup PNPM
|
|
uses: pnpm/action-setup@v2.2.1
|
|
|
|
- name: Setup Node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 16
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Build Packages
|
|
run: pnpm run build
|
|
|
|
- name: Create Release Pull Request or Publish
|
|
id: changesets
|
|
uses: changesets/action@v1
|
|
with:
|
|
# Note: pnpm install after versioning is necessary to refresh lockfile
|
|
version: pnpm run version
|
|
publish: pnpm exec changeset publish
|
|
commit: '[ci] release'
|
|
title: '[ci] release'
|
|
env:
|
|
# Needs access to push to main
|
|
GITHUB_TOKEN: ${{ secrets.FREDKBOT_GITHUB_TOKEN }}
|
|
# Needs access to publish to npm
|
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Generate Notification
|
|
id: notification
|
|
if: steps.changesets.outputs.published == 'true'
|
|
run: message=$(node scripts/notify/index.js '${{ steps.changesets.outputs.publishedPackages }}') && echo ::set-output name=message::${message//$'\n'/'%0A'}
|
|
|
|
- name: Discord Notification
|
|
if: steps.changesets.outputs.published == 'true'
|
|
id: discord-notification
|
|
env:
|
|
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
|
|
uses: Ilshidur/action-discord@0.3.2
|
|
with:
|
|
args: ${{ steps.notification.outputs.message }}
|