Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions .circleci/comment-artifacts.sh

This file was deleted.

154 changes: 0 additions & 154 deletions .circleci/config.yml

This file was deleted.

72 changes: 0 additions & 72 deletions .circleci/deploy-docs.sh

This file was deleted.

145 changes: 145 additions & 0 deletions .github/workflows/workflows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: build-and-test

on:
push:
branches:
- main
pull_request:

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about defining concurrency rules to limit runs on frequent pushes?

Suggested change
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.19.0'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we extract node version to env var? or use version from .nvmrc (setup-node action has an option node-version-file)

cache: 'yarn'
- run: corepack enable
- run: yarn --immutable
- run: yarn lint-no-fix

typescript:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.19.0'
cache: 'yarn'
- run: corepack enable
- run: yarn --immutable
- run: yarn typescript

unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't count, but looks like all jobs use the same steps (checkout, setup node, install deps...). Let's create a composite action with steps that we need to setup everything before we run a job.

- uses: actions/setup-node@v4
with:
node-version: '20.19.0'
cache: 'yarn'
- run: corepack enable
- run: yarn --immutable
- uses: actions/cache@v4
with:
path: ./cache/jest
key: jest-cache-${{ github.ref_name }}
restore-keys: jest-cache-
- name: Run unit tests
run: yarn test --maxWorkers=2 --coverage
- uses: actions/upload-artifact@v4
if: always()
with:
name: coverage
path: coverage

build-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.19.0'
cache: 'yarn'
- run: corepack enable
- run: yarn --immutable
- name: Build package
run: |
yarn prepack
node ./scripts/typescript-output-lint
build-docs:
if: github.ref != 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.19.0'
cache: 'yarn'
- run: corepack enable
- run: yarn --immutable
- name: Build docs
run: yarn --cwd docs build
- uses: actions/upload-artifact@v4
with:
name: docs
path: docs/build

comment-artifacts:
if: github.event_name == 'pull_request'
needs: build-docs
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/github-script@v7
with:
script: |
const artifactsUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}/artifacts`;
const body = `Hey @${context.payload.pull_request.user.login}, thank you for your pull request 🤗. The documentation from this branch can be viewed [here](${artifactsUrl}).`;
const marker = 'The documentation from this branch can be viewed';
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
deploy-docs:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deploy-docs runs even if checks fail. I'd run it when all steps pass

Suggested change
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, typescript, unit-tests, build-package]

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.19.0'
cache: 'yarn'
- run: corepack enable
- run: yarn --immutable
- name: Build docs
run: yarn --cwd docs build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
Loading