Skip to content

chore: modernize CI and add npm install option to README #1

chore: modernize CI and add npm install option to README

chore: modernize CI and add npm install option to README #1

Workflow file for this run

# GENERATED BY ./ci.ts -- DO NOT DIRECTLY EDIT
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- '*'
jobs:
build:
name: '${{ matrix.config.kind }} ${{ matrix.config.os }}'
runs-on: '${{ matrix.config.os }}'
strategy:
matrix:
config:
- os: ubuntu-latest
kind: test_release
- os: ubuntu-latest
kind: test_debug
env:
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: full
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- uses: dsherret/rust-toolchain-file@3551321aa44dd44a0393eb3b6bdfbc5d25ecf621 # v1
- name: Install wasm32 target
if: matrix.config.kind == 'test_release'
run: rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
with:
save-if: '${{ github.ref == ''refs/heads/main'' }}'
- uses: denoland/setup-deno@667a34cdef165d8d2b2e98dde39547c9daac7282 # v2
with:
deno-version: v2.x
- name: Build debug
if: matrix.config.kind == 'test_debug'
run: cargo build
- name: Build release
if: matrix.config.kind == 'test_release'
run: cargo build --target wasm32-unknown-unknown --features wasm --release
- name: Test debug
if: matrix.config.kind == 'test_debug'
run: cargo test
- name: Test release
if: matrix.config.kind == 'test_release'
run: cargo test --release
- name: Get tag version
id: get_tag_version
if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')'
run: 'echo "TAG_VERSION=${GITHUB_REF/refs\/tags\//}" >> "$GITHUB_OUTPUT"'
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6
if: matrix.config.kind == 'test_release'
with:
node-version: 24.x
registry-url: 'https://registry.npmjs.org'
- name: Setup and test npm deployment
if: matrix.config.kind == 'test_release'
run: |-
cd deployment/npm
npm install
node setup.js
npm run test
- name: Pre-release
if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')'
run: |-
# update config schema to have version
sed -i 's/jupyter\/0.0.0/jupyter\/${{ steps.get_tag_version.outputs.TAG_VERSION }}/' deployment/schema.json
# rename the wasm file
(cd target/wasm32-unknown-unknown/release/ && mv dprint_plugin_jupyter.wasm plugin.wasm)
# create release notes
deno run -A ./scripts/generate_release_notes.ts ${{ steps.get_tag_version.outputs.TAG_VERSION }} > ${{ github.workspace }}-CHANGELOG.txt
- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
if: 'matrix.config.kind == ''test_release'' && startsWith(github.ref, ''refs/tags/'')'
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
with:
files: |-
target/wasm32-unknown-unknown/release/plugin.wasm
deployment/schema.json
body_path: '${{ github.workspace }}-CHANGELOG.txt'
draft: false
- name: Lint workflow generation
if: matrix.config.kind == 'test_debug'
run: |-
./.github/workflows/ci.ts --lint
./.github/workflows/publish.ts --lint
./.github/workflows/release.ts --lint