Skip to content

Commit 728bb15

Browse files
committed
ci: factor Socket Firewall setup into a composite action
The three sfw smoke jobs (python / npm-fixture / pypi-fixture) repeated the same setup: toolchain bootstrap + socketdev/action install. GitHub Actions doesn't support YAML anchors, so extract the shared setup into a local composite action instead. - New .github/actions/setup-sfw: optional Python/Node/uv toolchain inputs + the socketdev/action (firewall-free) install. - Each job now just declares the toolchain it needs (`uv`, `node`, or `python`) and runs its own distinct sfw command. Net effect: the pinned socketdev/action SHA now lives in ONE place (future bumps touch a single line), the per-job setup-python/setup-node duplication is gone, and each job body is reduced to its actual firewall check. No behavior change. Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
1 parent c2bc561 commit 728bb15

2 files changed

Lines changed: 46 additions & 26 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: "Set up Socket Firewall (free)"
2+
description: >-
3+
Set up the requested language toolchain and install Socket Firewall (free
4+
edition) so subsequent steps can run package-manager commands wrapped with
5+
`sfw`. Free/anonymous mode -- no API token, safe on untrusted/Dependabot PRs.
6+
7+
inputs:
8+
python:
9+
description: "Set up Python 3.12"
10+
default: "false"
11+
node:
12+
description: "Set up Node 20 (needed for npm-wrapped checks)"
13+
default: "false"
14+
uv:
15+
description: "Install uv (implies Python)"
16+
default: "false"
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- if: ${{ inputs.python == 'true' || inputs.uv == 'true' }}
22+
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
23+
with:
24+
python-version: "3.12"
25+
26+
- if: ${{ inputs.node == 'true' }}
27+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
28+
with:
29+
node-version: "20"
30+
31+
# Official Socket setup action. Wires up sfw routing correctly -- preferred
32+
# over a hand-rolled `npm install -g sfw`. Pinned to a commit SHA (v1.3.2).
33+
- uses: socketdev/action@ba6de6cc0565af1f42295590380973573297e31f
34+
with:
35+
mode: firewall-free
36+
37+
- if: ${{ inputs.uv == 'true' }}
38+
name: Install uv
39+
shell: bash
40+
run: python -m pip install --upgrade pip uv

.github/workflows/dependabot-review.yml

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,9 @@ jobs:
9494
fetch-depth: 1
9595
persist-credentials: false
9696

97-
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
97+
- uses: ./.github/actions/setup-sfw
9898
with:
99-
python-version: "3.12"
100-
101-
# Official Socket setup action (free edition). Installs sfw and wires up
102-
# routing correctly -- preferred over a hand-rolled `npm install -g sfw`.
103-
- name: Set up Socket Firewall (free)
104-
uses: socketdev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
105-
with:
106-
mode: firewall-free
107-
108-
- name: Install uv
109-
run: python -m pip install --upgrade pip uv
99+
uv: "true"
110100

111101
- name: Sync project through Socket Firewall
112102
# `sfw uv sync` is the intended way to route uv through Socket Firewall
@@ -141,14 +131,9 @@ jobs:
141131
fetch-depth: 1
142132
persist-credentials: false
143133

144-
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
134+
- uses: ./.github/actions/setup-sfw
145135
with:
146-
node-version: "20"
147-
148-
- name: Set up Socket Firewall (free)
149-
uses: socketdev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
150-
with:
151-
mode: firewall-free
136+
node: "true"
152137

153138
- name: Install fixture through Socket Firewall
154139
working-directory: tests/e2e/fixtures/simple-npm
@@ -165,14 +150,9 @@ jobs:
165150
fetch-depth: 1
166151
persist-credentials: false
167152

168-
- uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3
169-
with:
170-
python-version: "3.12"
171-
172-
- name: Set up Socket Firewall (free)
173-
uses: socketdev/action@ba6de6cc0565af1f42295590380973573297e31f # v1.3.2
153+
- uses: ./.github/actions/setup-sfw
174154
with:
175-
mode: firewall-free
155+
python: "true"
176156

177157
- name: Install fixture through Socket Firewall
178158
working-directory: tests/e2e/fixtures/simple-pypi

0 commit comments

Comments
 (0)