Skip to content

Commit

Permalink
ci: CI on both Node 22 and Deno 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkluijk committed Nov 21, 2024
1 parent 87db0ff commit 65a40e8
Show file tree
Hide file tree
Showing 21 changed files with 507 additions and 301 deletions.
76 changes: 64 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,81 @@
name: Node.js CI
name: 'CI'

on: [push]
on: [ push ]

jobs:
build:
runs-on: ubuntu-latest

build_node:
name: "Build"
strategy:
matrix:
node-version: [22.x]
runtime: [ 'Node.js v22' ]

runs-on: ubuntu-latest


steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: 'Clone repository'
uses: actions/checkout@v4

- name: 'Install Node.js'
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- run: npm install
- run: npm run lint
- run: npm run test:ci
- name: Publish coverage badge

- name: 'npm ci'
run: npm ci

- name: 'npm run check-types'
run: npm run check-types

- name: 'npm run lint'
run: npm run lint

- name: 'npm run test'
run: npm run test:ci
# todo: convert test:ci to a convention for env var detection "e.g. CI=true"

- name: 'Publish coverage badge'
uses: wjervis7/vitest-badge-action@v1.0.0
with:
result-type: lines
gist-token: ${{ secrets.RELEASE_PLEASE_TOKEN }} # if you want to upload badge to gist
gist-url: https://gist.github.com/dirkluijk/db6fbd0d0d4c138655a89386c5bdbe41
upload-badge: ${{ github.ref == 'refs/heads/main' }}
badge-text: 'coverage'

build_deno:
name: "Build"
strategy:
matrix:
runtime: [ 'Deno v2' ]

runs-on: ubuntu-latest


permissions:
id-token: write # Needed for auth with Deno Deploy
contents: read # Needed to clone the repository

steps:
- name: 'Clone repository'
uses: actions/checkout@v4

- name: 'Install Deno'
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: 'deno install'
run: deno install

- name: 'deno check'
run: deno check **/*.ts

- name: 'deno lint'
run: deno run lint

- name: 'deno test'
# todo: use "deno run test:ci" when released:
# https://github.com/denoland/deno/pull/26836
run: deno run test
36 changes: 23 additions & 13 deletions .github/workflows/deploy.yml → .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy VitePress site to Pages
name: 'Docs'

on:
push:
Expand All @@ -21,37 +21,47 @@ concurrency:

jobs:
build:
name: Build docs
name: 'Build docs'

runs-on: ubuntu-latest

steps:
- name: Checkout
- name: 'Clone repository'
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node

- name: 'Install Node.js'
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm # or pnpm / yarn
- name: Setup Pages
cache: npm

- name: 'Setup Pages'
uses: actions/configure-pages@v4
- name: Install dependencies

- name: 'npm ci'
run: npm ci
- name: Build with VitePress

- name: 'npm run docs:build'
run: npm run docs:build
- name: Upload artifact

- name: 'Upload artifact for Pages'
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

deploy:
name: Deploy docs
name: 'Deploy docs'
needs: build

runs-on: ubuntu-latest

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest

steps:
- name: Deploy to GitHub Pages
- name: 'Deploy to GitHub Pages'
id: deployment
uses: actions/deploy-pages@v4
33 changes: 22 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Release
name: 'Release'

on:
push:
Expand All @@ -16,26 +16,37 @@ jobs:
contents: read
id-token: write
steps:
- uses: googleapis/release-please-action@v4
- name: 'Release please!'
id: release
uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
- uses: actions/checkout@v4

- name: 'Clone repository (if release)'
if: ${{ steps.release.outputs.release_created }}
uses: actions/checkout@v4

- name: 'Install Node.js (if release)'
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v4
uses: actions/setup-node@v4
with:
node-version: 22
registry-url: 'https://registry.npmjs.org'

- name: 'npm ci (if release)'
if: ${{ steps.release.outputs.release_created }}
- run: npm install
if: ${{ steps.release.outputs.release_created }}
- run: npm run build
run: npm ci

- name: 'npx jsr publish --allow-dirty (if release)'
if: ${{ steps.release.outputs.release_created }}
- run: npm run test
run: npx jsr publish --allow-dirty

- name: 'npm run compile (if release)'
if: ${{ steps.release.outputs.release_created }}
- run: npx jsr publish --allow-dirty
run: npm run compile

- name: 'npm publish (if release)'
if: ${{ steps.release.outputs.release_created }}
- run: npm publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.release_created }}
Loading

0 comments on commit 65a40e8

Please sign in to comment.