Skip to content

Commit f8a26fc

Browse files
committed
Add GitHub workflows and VSCode test debug config
1 parent 86199f0 commit f8a26fc

3 files changed

Lines changed: 118 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
ci:
12+
name: Build, test & lint
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out repository
16+
uses: actions/checkout@v3
17+
18+
- name: Setup PNPM
19+
uses: pnpm/action-setup@v2
20+
with:
21+
version: 8
22+
23+
- name: Setup Node.js
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: 18
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Build packages
33+
run: pnpm build
34+
35+
- name: Run tests with coverage
36+
run: pnpm coverage
37+
38+
- name: Lint source code
39+
run: pnpm lint

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
10+
jobs:
11+
release:
12+
name: Release
13+
if: github.repository_owner == 'expressive-code'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Check out repository
17+
uses: actions/checkout@v3
18+
19+
- name: Setup PNPM
20+
uses: pnpm/action-setup@v2
21+
with:
22+
version: 8
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: 18
28+
cache: 'pnpm'
29+
30+
- name: Install dependencies
31+
run: pnpm install --frozen-lockfile
32+
33+
- name: Check for unreleased changesets
34+
id: has-changesets
35+
uses: andstor/file-existence-action@v2
36+
with:
37+
files: ".changeset/!(README).md"
38+
39+
# If there are unreleased changesets, validate the project before creating the changesets PR
40+
- name: Require build, test and lint to pass
41+
if: steps.has-changesets.outputs.files_exists == 'true'
42+
run: |
43+
pnpm build
44+
pnpm test
45+
pnpm lint
46+
47+
# Run changesets action either if there are unreleased changesets (= a PR must be created)
48+
# or if the commit message matches the release PR (= new versions must be published to NPM)
49+
- name: Create changesets PR or publish to NPM
50+
id: changesets
51+
if: steps.has-changesets.outputs.files_exists == 'true' || startsWith(github.event.head_commit.message, '[CI] Release')
52+
uses: changesets/action@v1
53+
with:
54+
title: '[CI] Release'
55+
commit: '[CI] Release'
56+
version: 'pnpm ci-version'
57+
publish: 'pnpm ci-publish'
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.vscode/launch.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "node",
9+
"request": "launch",
10+
"name": "Debug Current Test File",
11+
"autoAttachChildProcesses": true,
12+
"skipFiles": ["<node_internals>/**", "**/node_modules/**"],
13+
"program": "${workspaceRoot}/node_modules/vitest/vitest.mjs",
14+
"args": ["run", "${relativeFile}"],
15+
"smartStep": true,
16+
"console": "integratedTerminal"
17+
}
18+
]
19+
}

0 commit comments

Comments
 (0)