Skip to content

Commit d5f0ce0

Browse files
committed
add actions and workflow
1 parent 214988b commit d5f0ce0

4 files changed

Lines changed: 147 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Install dependencies for github-script actions
2+
description: Installs dependencies for github-script actions
3+
4+
runs:
5+
using: composite
6+
7+
steps:
8+
- uses: ./.github/actions/setup-node-install-deps
9+
with:
10+
# actions/github-script@v8 uses Node 24
11+
node-version: 24.x
12+
# "--no-audit": improves performance
13+
# "--no-fund": improves performance
14+
# "--prefer-offline": improves performance
15+
# "--omit dev": not needed at runtime, improves performance
16+
install-command: "npm ci --no-audit --no-fund --prefer-offline --omit dev"
17+
working-directory: ./.github
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Setup Node and install dependencies
2+
description: Uses specified Node version and installs dependencies (typically using "npm")
3+
4+
inputs:
5+
node-version:
6+
description: "Node version to use"
7+
default: 24.x
8+
install-command:
9+
description: "Command to install dependencies"
10+
default: "npm ci --no-audit --no-fund --prefer-offline"
11+
working-directory:
12+
description: "Working directory"
13+
default: "."
14+
15+
runs:
16+
using: "composite"
17+
18+
steps:
19+
- uses: actions/setup-node@v6
20+
with:
21+
node-version: ${{ inputs.node-version }}
22+
cache: "npm"
23+
cache-dependency-path: ${{ inputs.working-directory }}/package-lock.json
24+
25+
- run: |
26+
echo "::group::$INSTALL_COMMAND"
27+
$INSTALL_COMMAND
28+
echo "::endgroup::"
29+
shell: bash
30+
env:
31+
INSTALL_COMMAND: ${{ inputs.install-command }}
32+
working-directory: ${{ inputs.working-directory }}
33+
34+
- run: |
35+
echo "::group::npm ls -a"
36+
npm ls -a || true
37+
echo "::endgroup::"
38+
shell: bash
39+
working-directory: ${{ inputs.working-directory }}

.github/matchers/actionlint.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "actionlint",
5+
"pattern": [
6+
{
7+
"regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$",
8+
"file": 1,
9+
"line": 2,
10+
"column": 3,
11+
"message": 4,
12+
"code": 5
13+
}
14+
]
15+
}
16+
]
17+
}

.github/workflows/github-test.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: GitHub Actions - Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- .github/**
9+
pull_request:
10+
paths:
11+
- .github/**
12+
workflow_dispatch:
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
test:
19+
strategy:
20+
matrix:
21+
folder: [.github, .github/shared]
22+
os: [ubuntu, windows]
23+
24+
runs-on: ${{ fromJSON('{"ubuntu":"ubuntu-24.04", "windows":"windows-2022"}')[matrix.os] }}
25+
26+
defaults:
27+
run:
28+
working-directory: ./${{ matrix.folder }}
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v6
33+
with:
34+
sparse-checkout: |
35+
.github
36+
37+
- if: ${{ matrix.folder == '.github' }}
38+
name: Install dependencies for github-script actions
39+
uses: ./.github/actions/install-deps-github-script
40+
41+
- if: ${{ matrix.folder == '.github' }}
42+
name: Verify all modules are importable
43+
uses: actions/github-script@v8
44+
with:
45+
script: |
46+
const { join } = await import("path");
47+
const { pathToFileURL } = await import("url");
48+
const fullPath = join(process.env.GITHUB_WORKSPACE, ".github", "workflows", "src", "github-test.js");
49+
const { default: importAllModules } = await import(pathToFileURL(fullPath).href);
50+
await importAllModules({ core });
51+
52+
- name: Install dev deps
53+
uses: ./.github/actions/setup-node-install-deps
54+
with:
55+
# actions/github-script@v8 uses Node 24
56+
node-version: 24.x
57+
working-directory: ./${{ matrix.folder }}
58+
59+
- run: npm run test:ci
60+
61+
- run: npm run lint
62+
63+
- run: npm run format:check:ci
64+
65+
# Content copied from https://raw.githubusercontent.com/rhysd/actionlint/2ab3a12c7848f6c15faca9a92612ef4261d0e370/.github/actionlint-matcher.json
66+
- if: ${{ matrix.folder == '.github' && matrix.os == 'ubuntu'}}
67+
name: Add ActionLint Problem Matcher
68+
run: echo "::add-matcher::.github/matchers/actionlint.json"
69+
70+
- if: ${{ matrix.folder == '.github' && matrix.os == 'ubuntu'}}
71+
name: Lint workflows
72+
uses: docker://rhysd/actionlint:1.7.12@sha256:b1934ee5f1c509618f2508e6eb47ee0d3520686341fec936f3b79331f9315667
73+
with:
74+
args: -color -verbose

0 commit comments

Comments
 (0)