Skip to content

Commit 6b11847

Browse files
authored
chore: add devcontainer and convert to pnpm (#47)
This patch sets up a devcontainer for working locally. As well as converts to pnpm for the package manager.
1 parent 3ac35d8 commit 6b11847

13 files changed

Lines changed: 1680 additions & 2308 deletions

.devcontainer/Dockerfile

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
FROM node:24-bookworm-slim AS node-src
2+
FROM rhysd/actionlint:1.7.8 AS actionlint-src
3+
FROM ghcr.io/hadolint/hadolint:v2.14.0-debian AS hadolint-src
4+
FROM ghcr.io/zizmorcore/zizmor:1.21.0 AS zizmor-src
5+
6+
# Just setting this one up for re-use so it only needs to be updated in one place.
7+
# Useful in case we add new stages so the same base is used everywhere.
8+
FROM ubuntu:noble-20260113 AS base-runtime
9+
10+
FROM base-runtime AS dev-runtime
11+
12+
SHELL ["/bin/bash", "-euC", "-o", "pipefail", "-c"]
13+
14+
ARG DEBIAN_FRONTEND=noninteractive
15+
16+
ENV NODE_ENV=development \
17+
NPM_CONFIG_PREFIX=/usr/local \
18+
PNPM_HOME=/opt/pnpm \
19+
PNPM_STORE_PATH=/pnpm-store \
20+
PATH="/home/ubuntu/.local/bin:/usr/local/lib/node_modules/bin:/opt/pnpm:/usr/local/go/bin:/usr/local/bin:/usr/bin:${PATH}"
21+
22+
RUN <<EOF
23+
GLOBAL_NODE_MODULES="/usr/local/lib/node_modules"
24+
groupadd -r docker
25+
usermod -aG staff ubuntu
26+
usermod -aG docker ubuntu
27+
usermod -aG docker root
28+
chown -R root:staff /usr/local/bin
29+
mkdir -p "${GLOBAL_NODE_MODULES}" \
30+
"${PNPM_HOME}" \
31+
"${PNPM_STORE_PATH}" \
32+
/etc/apt/sources.list.d \
33+
/etc/apt/keyrings
34+
chmod 755 /etc/apt/keyrings
35+
chmod 755 /etc/apt/sources.list.d
36+
chmod -R 0775 "${PNPM_HOME}" "${GLOBAL_NODE_MODULES}" /usr/local/bin
37+
chmod -R 0777 "${PNPM_STORE_PATH}"
38+
chown -R ubuntu:staff "${PNPM_HOME}" "${PNPM_STORE_PATH}" "${GLOBAL_NODE_MODULES}"
39+
chmod -R g+sw "${PNPM_HOME}" "${PNPM_STORE_PATH}" "${GLOBAL_NODE_MODULES}"
40+
EOF
41+
42+
# Bring in toolchains/artifacts (optimized with --link)
43+
COPY --link --from=hadolint-src /bin/hadolint /usr/local/bin/
44+
COPY --link --from=zizmor-src /usr/bin/zizmor /usr/local/bin/zizmor
45+
## Actionlint also has shellcheck in its bin
46+
COPY --link --from=actionlint-src /usr/local/bin/ /usr/local/bin/
47+
48+
# Symlink-dependent toolchains (cannot use --link)
49+
COPY --from=node-src \
50+
--chown=0:50 \
51+
--exclude=*CHANGELOG.md \
52+
--exclude=*README.md \
53+
--exclude=bin/docker-entrypoint.sh \
54+
/usr/local/ /usr/local/
55+
COPY --from=node-src \
56+
--chown=0:50 \
57+
/opt /opt
58+
59+
RUN --mount=type=cache,target=/var/cache/apt,id=apt-archives,sharing=shared \
60+
--mount=type=cache,target=/var/lib/apt/lists,id=apt-lists,sharing=locked \
61+
<<EOF
62+
apt-get update
63+
apt-get install -y --no-install-recommends \
64+
curl \
65+
software-properties-common \
66+
ca-certificates
67+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
68+
chmod 0044 /etc/apt/keyrings/githubcli-archive-keyring.gpg
69+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
70+
apt-get update
71+
apt-get install -y --no-install-recommends \
72+
gh \
73+
git \
74+
sudo
75+
76+
# Setup sudo access
77+
echo "ubuntu ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/ubuntu
78+
chmod 0440 /etc/sudoers.d/ubuntu
79+
80+
# Global npm configuration
81+
## This sets config for both root and regular users.
82+
## Use the heredoc syntax so we also get comments in the image for reference in-use.
83+
cat > /usr/local/etc/npmrc <<EONPMRC
84+
## Disable funding messages and automatic audits
85+
fund=false
86+
audit=false
87+
## Prefer the offline modules when possible to speed up installs
88+
## Particularly useful in CI environments with caching enabled
89+
prefer-offline=true
90+
## Help network or registry issues by massaging the network config
91+
## It is balanced to slowly back off up to the 120ms max on the
92+
## final attempt.
93+
## It should go like this: 3.75s, 7.5s, 15s, 30s, 60s, 120s.
94+
## We politely back-off and delay instead of rushing retries
95+
## so the registry is not hammered to cause an outage.
96+
fetch-retries=6
97+
fetch-retry-factor=2
98+
fetch-retry-mintimeout=3750
99+
fetch-retry-maxtimeout=120000
100+
## Setup logging to be more efficient for containers
101+
## Keep the default log level, but discard logs going to a fail.
102+
loglevel=notice
103+
logs-dir=/dev/null
104+
EONPMRC
105+
106+
# Install pnpm globally
107+
curl -fsSL https://get.pnpm.io/install.sh | \
108+
env PNPM_HOME="${PNPM_HOME}" \
109+
SHELL=/bin/bash \
110+
bash -
111+
112+
# Install GitHub copilot
113+
curl -fsSL https://gh.io/copilot-install | bash
114+
115+
EOF
116+
117+
WORKDIR /workspace

.devcontainer/devcontainer.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
3+
{
4+
"name": "Runner Resource Usage",
5+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6+
"build": {
7+
"dockerfile": "Dockerfile"
8+
},
9+
10+
// Features to add to the dev container. More info: https://containers.dev/features.
11+
// "features": {},
12+
13+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
14+
// "forwardPorts": [],
15+
16+
// Use 'postCreateCommand' to run commands after the container is created.
17+
// "postCreateCommand": "yarn install",
18+
19+
// Configure tool-specific properties.
20+
// "customizations": {},
21+
22+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
23+
"remoteUser": "ubuntu"
24+
}

.github/agents/trunk-based-dev.agent.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -466,20 +466,20 @@ jobs:
466466
- uses: actions/setup-node@v4
467467
with:
468468
node-version: '24'
469-
cache: 'npm'
470-
- run: npm ci
471-
- run: npm test
472-
- run: npm run build
473-
469+
cache: 'pnpm'
470+
- run: pnpm ci
471+
- run: pnpm test
472+
- run: pnpm build
473+
474474
dist-check:
475475
runs-on: ubuntu-24.04
476476
timeout-minutes: 5
477477
steps:
478478
- uses: actions/checkout@v4
479479
- name: Verify dist/ is up to date
480480
run: |
481-
npm ci
482-
npm run build
481+
pnpm ci
482+
pnpm build
483483
git diff --exit-code dist/
484484
```
485485

.github/workflows/actionlint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
run: actionlint -format "$(cat .github/formatters/actionlint-sarif.gotmpl)" .github/workflows/*.yml > actionlint.sarif
4646
- name: Upload SARIF File
4747
if: ${{ always() }} # Ensure this runs even if the actionlint step fails, so we get results in the Security tab.
48-
uses: github/codeql-action/upload-sarif@45cbd0c69e560cd9e7cd7f8c32362050c9b7ded2 # v4.32.2
48+
uses: github/codeql-action/upload-sarif@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
4949
with:
5050
sarif_file: actionlint.sarif
5151
category: actionlint

.github/workflows/codeql.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ jobs:
3636
- name: Start Workflow Telemetry
3737
uses: ./
3838
- name: Initialize CodeQL
39-
uses: github/codeql-action/init@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
39+
uses: github/codeql-action/init@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
4040
with:
4141
languages: ${{ matrix.language }}
4242
config-file: ./.github/codeql/codeql-config.yml
4343
- name: Perform CodeQL Analysis
44-
uses: github/codeql-action/analyze@9e907b5e64f6b83e7804b09294d44122997950d6 # v4.32.3
44+
uses: github/codeql-action/analyze@89a39a4e59826350b863aa6b6252a07ad50cf83e # v4.32.4
4545
with:
4646
category: "/language:${{matrix.language}}"

.github/workflows/copilot-setup-steps.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,15 @@ jobs:
4646
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4747
with:
4848
persist-credentials: false
49+
- name: Setup pnpm
50+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
4951
- name: Setup Node.js
5052
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
5153
with:
5254
node-version-file: .node-version
53-
cache: npm
55+
cache: pnpm
5456
- name: Install Dependencies
55-
run: npm ci
57+
run: pnpm install
5658
- name: Install Actionlint
5759
env:
5860
TMP_DIR: ${{ runner.temp }}

.github/workflows/test-action.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,20 @@ jobs:
4040
- name: Start Workflow Telemetry
4141
uses: ./
4242

43+
- name: Setup pnpm
44+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0
45+
4346
- name: Setup Node.js
4447
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
4548
with:
46-
node-version: "24"
49+
node-version-file: .node-version
50+
cache: pnpm
4751

4852
- name: Install Dependencies
49-
run: npm ci
53+
run: pnpm install
5054

5155
- name: Run Tests
52-
run: npm test
56+
run: pnpm test
5357

5458
test-resource-load:
5559
name: Test with Resources Under Load (${{ matrix.os }})
@@ -87,7 +91,7 @@ jobs:
8791
run: |
8892
set -euo pipefail
8993
echo "Starting CPU-intensive activity for 15 seconds..."
90-
94+
9195
# Create test file based on OS
9296
if [[ "$RUNNER_OS" == "Windows" ]]; then
9397
echo "Creating 5GB test file on Windows..."
@@ -134,7 +138,7 @@ jobs:
134138
run: |
135139
set -euo pipefail
136140
echo "Starting memory-intensive activity for 15 seconds..."
137-
141+
138142
# Determine memory allocation size based on OS
139143
# macOS runners have less memory available, so we allocate less
140144
if [[ "$RUNNER_OS" == "macOS" ]]; then
@@ -144,7 +148,7 @@ jobs:
144148
export ARRAY_COUNT=50
145149
echo "Running on $RUNNER_OS - allocating ~500MB of memory"
146150
fi
147-
151+
148152
node -e "
149153
const arrays = [];
150154
const startTime = Date.now();

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ build/Release
135135

136136
# Dependency directories
137137
node_modules/
138+
.pnpm-store/
138139
jspm_packages/
139140

140141
# Snowpack dependency directory (https://snowpack.dev/)

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ When updating one, update the other accordingly. Note that action.yml's descript
3838
Requires Node.js 24.x.
3939

4040
```bash
41-
npm ci # Install dependencies
42-
npm test # Run all tests
41+
pnpm install # Install dependencies
42+
pnpm test # Run all tests
4343
```
4444

4545
## Architecture

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ jobs:
115115
uses: actions/checkout@v6
116116

117117
- name: Run tests
118-
run: npm test
118+
run: pnpm test
119119

120120
# ... other steps
121121
```
@@ -149,7 +149,7 @@ jobs:
149149
uses: actions/checkout@v6
150150

151151
- name: Run tests
152-
run: npm test
152+
run: pnpm test
153153

154154
# ... other steps
155155
```
@@ -196,7 +196,7 @@ The `runner.debug` context is documented in the [GitHub Actions contexts referen
196196
### 1. Install Dependencies
197197

198198
```bash
199-
npm ci
199+
pnpm ci
200200
```
201201

202202
This automatically runs gitleaks on commit.
@@ -206,10 +206,10 @@ It checks for sensitive information like API keys or tokens.
206206

207207
```bash
208208
# Bundle for operation in a workflow
209-
npm run build
209+
pnpm build
210210

211211
# Run unit tests (Node test runner)
212-
npm test
212+
pnpm test
213213
```
214214

215215
## Project Structure

0 commit comments

Comments
 (0)