Skip to content
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/ci.generated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# GENERATED BY ./ci.ts -- DO NOT DIRECTLY EDIT

name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
permissions: {}
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}"
cancel-in-progress: true
jobs:
ci:
name: CI
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: dprint/check@7dc032d8874778fc024f6f9b4a7e6d896782c330 # v2
with:
cache: true
- name: Install dependencies
run: npm install
- name: Lint CI generation
run: npx gagen --lint
- name: Type check
run: npx tsc --noEmit
- name: Run tests
env:
DPRINT_PLUGINS_GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: npx vitest run
49 changes: 49 additions & 0 deletions .github/workflows/ci.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env node
import { expr, job, step, workflow } from "gagen";

const checkout = step({ name: "Checkout", uses: "actions/checkout@v7", with: { "persist-credentials": false } });
const installDeps = step.dependsOn(checkout)({ name: "Install dependencies", run: "npm install" });

const ciJob = job("ci", {
name: "CI",
runsOn: "ubuntu-latest",
permissions: { contents: "read" },
steps: step(
step.dependsOn(checkout)({
uses: "dprint/check@v2",
with: { cache: true },
}),
step.dependsOn(installDeps)({
name: "Lint CI generation",
run: "npx gagen --lint",
}),
step.dependsOn(installDeps)({ name: "Type check", run: "npx tsc --noEmit" }),
step.dependsOn(installDeps)({
name: "Run tests",
run: "npx vitest run",
env: {
// the tests make requests to the GitHub API, which rate limits
// unauthenticated requests by the IP address of the shared runner
DPRINT_PLUGINS_GH_TOKEN: expr("secrets.GITHUB_TOKEN"),
},
}),
),
});

workflow({
name: "CI",
on: {
pull_request: { branches: ["main"] },
push: { branches: ["main"] },
},
permissions: {},
concurrency: {
// https://stackoverflow.com/a/72408109/188246
group: "${{ github.workflow }}-${{ github.head_ref || github.run_id }}",
cancelInProgress: true,
},
jobs: [ciJob],
}).writeOrLint({
filePath: new URL("./ci.generated.yml", import.meta.url),
header: "# GENERATED BY ./ci.ts -- DO NOT DIRECTLY EDIT",
});
19 changes: 0 additions & 19 deletions .github/workflows/ci.yml

This file was deleted.

Loading
Loading