astro/.github/workflows/ci.yml
Nate Moore 93e1020b1e
Fix: reintroduce smoke tests across example projects (#3669)
* chore: update smoke tests

* chore: bump smoke tests to node@16

* chore: remove gitmodules

* chore(ci): prefer node@14

* wip: remove path from smoke clone step

* feat: run build:examples from test:smoke

* fix: remove no-frozen-lockfile

* fix: checkout monorepo last for pnpm setup

* wip: replace @astrojs/markdown/remark import from md

* fix: remove type defs from generated file

* fix: function order

* chore: remove ssr-utils export

* wip: remove windows from smoke test

* fix: instantiate slugger in snippet

* fix: exclude with-mdx from smoke (for now)

* fix: add quotes on filter flag for safety

* chore: changeset

* wip: try reintroducing windows smoke

* sad chore: remove client: directive from with-mdx

* Revert "wip: try reintroducing windows smoke"

This reverts commit 9529b1a45c.

Co-authored-by: Nate Moore <nate@astro.build>
Co-authored-by: bholmesdev <hey@bholmes.dev>
2022-07-11 22:51:17 -04:00

267 lines
7 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 docs
uses: actions/checkout@v3
with:
repository: withastro/docs
- name: Checkout astro.build
uses: actions/checkout@v3
with:
repository: withastro/astro.build
- 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: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 }}