mirror of
https://github.com/outline/outline.git
synced 2026-11-25 15:15:15 +03:00
* chore: Speed up CI with TypeScript 7 and Blacksmith runners Upgrade TypeScript to 7.0.2, the native compiler, which cuts a full type check from ~57s to ~12s locally. Yarn is bumped to 4.18.0 because older versions fail to apply the builtin compat patch to TypeScript 7. Fix two type errors the stricter compiler surfaces: the collection drop target used unrelated item and monitor types, and Store.add relied on the error type of an abstract construct call to satisfy the generic return. Move CI jobs to Blacksmith runners, with a fallback to GitHub-hosted runners for forks. * chore: Match enterprise CI runner sizes * chore: Persist node_modules on a sticky disk and use more test workers * chore: Use the preinstalled PostgreSQL in CI instead of a service container * chore: Skip the setup-node yarn cache when a sticky disk is mounted * chore: Persist the Node.js toolcache and run server tests in 6 shards * chore: Disable the setup-node package manager cache on Blacksmith * chore: Keep pull requests from forks off Blacksmith runners and sticky disks
170 lines
5.9 KiB
YAML
170 lines
5.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
env:
|
|
NODE_ENV: test
|
|
DATABASE_URL: postgres://postgres:password@localhost:5432/outline_test
|
|
REDIS_URL: redis://127.0.0.1:6379
|
|
URL: http://localhost:3000
|
|
NODE_OPTIONS: --max-old-space-size=8192
|
|
SECRET_KEY: F0E5AD933D7F6FD8F4DBB3E038C501C052DC0593C686D21ACB30AE205D2F634B
|
|
UTILS_SECRET: 123456
|
|
SLACK_VERIFICATION_TOKEN: 123456
|
|
SMTP_USERNAME: localhost
|
|
|
|
jobs:
|
|
changes:
|
|
# Blacksmith runners are only available to the outline organization, and are
|
|
# not used for pull requests from forks so that fork-controlled code cannot
|
|
# write to the shared sticky disks. Keep in sync with actions/install.
|
|
runs-on: ${{ (github.repository_owner == 'outline' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)) && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-latest' }}
|
|
outputs:
|
|
runner: ${{ (github.repository_owner == 'outline' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)) && 'blacksmith-8vcpu-ubuntu-2404' || 'ubuntu-latest' }}
|
|
code: ${{ steps.filter.outputs.code }}
|
|
config: ${{ steps.filter.outputs.config }}
|
|
server: ${{ steps.filter.outputs.server }}
|
|
app: ${{ steps.filter.outputs.app }}
|
|
deps: ${{ steps.filter.outputs.deps }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
code:
|
|
- '**'
|
|
- '!**/*.md'
|
|
- '!docs/**'
|
|
- '!public/**'
|
|
- '!shared/i18n/locales/**'
|
|
config:
|
|
- '.github/**'
|
|
- 'vite.config.ts'
|
|
- 'vitest.config.ts'
|
|
server:
|
|
- 'server/**'
|
|
- 'shared/**'
|
|
- 'plugins/**'
|
|
- 'package.json'
|
|
- 'yarn.lock'
|
|
app:
|
|
- 'app/**'
|
|
- 'shared/**'
|
|
- 'package.json'
|
|
- 'yarn.lock'
|
|
deps:
|
|
- 'package.json'
|
|
- 'yarn.lock'
|
|
- '.yarnrc.yml'
|
|
|
|
lint:
|
|
needs: changes
|
|
if: ${{ needs.changes.outputs.code == 'true' }}
|
|
runs-on: ${{ needs.changes.outputs.runner }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: ./.github/actions/install
|
|
- run: yarn lint --quiet
|
|
|
|
actionlint:
|
|
needs: changes
|
|
if: ${{ needs.changes.outputs.config == 'true' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: docker://rhysd/actionlint:1.7.12
|
|
with:
|
|
args: -color
|
|
|
|
types:
|
|
needs: changes
|
|
if: ${{ needs.changes.outputs.code == 'true' }}
|
|
runs-on: ${{ needs.changes.outputs.runner }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: ./.github/actions/install
|
|
- run: yarn tsc
|
|
|
|
audit:
|
|
needs: changes
|
|
if: ${{ needs.changes.outputs.deps == 'true' }}
|
|
runs-on: ${{ needs.changes.outputs.runner }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: ./.github/actions/install
|
|
- run: yarn npm audit --severity high --recursive --environment production
|
|
|
|
test:
|
|
needs: changes
|
|
if: ${{ needs.changes.outputs.app == 'true' || needs.changes.outputs.config == 'true' }}
|
|
runs-on: ${{ needs.changes.outputs.runner }}
|
|
strategy:
|
|
matrix:
|
|
test-group: [app, shared]
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: ./.github/actions/install
|
|
- run: yarn test:${{ matrix.test-group }}
|
|
|
|
test-server:
|
|
needs: changes
|
|
if: ${{ needs.changes.outputs.server == 'true' || needs.changes.outputs.config == 'true' }}
|
|
runs-on: ${{ needs.changes.outputs.runner }}
|
|
strategy:
|
|
matrix:
|
|
shard: [1, 2, 3, 4, 5, 6]
|
|
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
# The runner image ships with PostgreSQL preinstalled, starting it is much
|
|
# faster than pulling and initializing a service container.
|
|
- name: Start PostgreSQL
|
|
run: |
|
|
sudo systemctl start postgresql.service
|
|
until pg_isready -h localhost; do sleep 1; done
|
|
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'password';"
|
|
sudo -u postgres createdb outline_test
|
|
- uses: ./.github/actions/install
|
|
- run: yarn sequelize db:migrate
|
|
- name: Run server tests
|
|
run: yarn test:server --maxWorkers=4 --shard=${{ matrix.shard }}/6
|
|
|
|
bundle-size:
|
|
needs: changes
|
|
if: ${{ (needs.changes.outputs.app == 'true' || needs.changes.outputs.config == 'true') && github.repository == 'outline/outline' }}
|
|
runs-on: ${{ needs.changes.outputs.runner }}
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
- uses: ./.github/actions/install
|
|
- name: Set environment to production
|
|
run: echo "NODE_ENV=production" >> "$GITHUB_ENV"
|
|
- run: yarn vite:build
|
|
- name: Send bundle stats to RelativeCI
|
|
if: ${{ env.RELATIVE_CI_KEY != '' }}
|
|
env:
|
|
RELATIVE_CI_KEY: ${{ secrets.RELATIVE_CI_KEY }}
|
|
uses: relative-ci/agent-action@38328454d6a23942175eba485fca4fbb807b1f03 # v2
|
|
with:
|
|
key: ${{ secrets.RELATIVE_CI_KEY }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
webpackStatsFile: ./build/app/webpack-stats.json
|
|
|
|
# Always runs, so it can be used as the single required status check. Jobs
|
|
# above are skipped when irrelevant to the changes, which is a pass here.
|
|
# Audit is intentionally excluded, it reports advisories that can have no
|
|
# fix available or affect dev only and should not block merging.
|
|
ci:
|
|
needs: [changes, lint, actionlint, types, test, test-server, bundle-size]
|
|
if: always()
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check job results
|
|
if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
|
|
run: |
|
|
echo "One or more jobs failed or were cancelled."
|
|
exit 1
|