Skip to content

Commit eba8c29

Browse files
committed
fix: stabilize release and provider CI
1 parent fe12359 commit eba8c29

8 files changed

Lines changed: 70 additions & 47 deletions

File tree

.github/workflows/publish.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ jobs:
3636
env:
3737
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
3838
GH_TOKEN: ${{ github.token }}
39+
PYPI_PAT_SECRET: ${{ secrets.PYPI_PAT_SECRET }}
3940
run: ./bin/release.sh

.github/workflows/tests.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
build:
4545
needs: precheck
4646
runs-on: ${{ matrix.os }}
47+
env:
48+
PNPM_HOME: ${{ runner.temp }}/pnpm
4749
strategy:
4850
fail-fast: true
4951
matrix:
@@ -64,6 +66,16 @@ jobs:
6466
enable-cache: true
6567
cache-dependency-glob: "uv.lock"
6668

69+
- name: Setup pnpm
70+
uses: pnpm/action-setup@v4
71+
with:
72+
version: 10
73+
74+
- name: Setup Node
75+
uses: actions/setup-node@v4
76+
with:
77+
node-version: '22'
78+
6779
- name: Install Nix on macOS
6880
if: runner.os == 'macOS'
6981
uses: DeterminateSystems/nix-installer-action@v16
@@ -73,16 +85,21 @@ jobs:
7385
uv venv --python "${{ matrix.python_version }}" \
7486
&& uv sync --all-extras \
7587
&& uv pip install pip \
88+
&& mkdir -p "$PNPM_HOME" \
89+
&& echo "$PNPM_HOME" >> "$GITHUB_PATH" \
7690
&& echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH" \
7791
&& if [ -d /nix/var/nix/profiles/default/bin ]; then echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"; fi
7892
7993
- name: Run standard test suite
8094
run: |
8195
source .venv/bin/activate \
96+
&& export PATH="$PNPM_HOME:$PATH" \
8297
&& python tests.py
8398
8499
live-integration:
85100
runs-on: ${{ matrix.os }}
101+
env:
102+
PNPM_HOME: ${{ runner.temp }}/pnpm
86103
strategy:
87104
fail-fast: true
88105
matrix:
@@ -102,6 +119,16 @@ jobs:
102119
enable-cache: true
103120
cache-dependency-glob: "uv.lock"
104121

122+
- name: Setup pnpm
123+
uses: pnpm/action-setup@v4
124+
with:
125+
version: 10
126+
127+
- name: Setup Node
128+
uses: actions/setup-node@v4
129+
with:
130+
node-version: '22'
131+
105132
- name: Install Nix
106133
uses: DeterminateSystems/nix-installer-action@v16
107134

@@ -121,6 +148,8 @@ jobs:
121148
uv venv --python "3.12" \
122149
&& uv sync --all-extras \
123150
&& uv pip install pip \
151+
&& mkdir -p "$PNPM_HOME" \
152+
&& echo "$PNPM_HOME" >> "$GITHUB_PATH" \
124153
&& echo "/home/linuxbrew/.linuxbrew/bin" >> "$GITHUB_PATH" \
125154
&& echo "/nix/var/nix/profiles/default/bin" >> "$GITHUB_PATH"
126155
@@ -134,6 +163,7 @@ jobs:
134163
if: runner.os == 'macOS'
135164
run: |
136165
source .venv/bin/activate \
166+
&& export PATH="$PNPM_HOME:$PATH" \
137167
&& python -m unittest \
138168
tests.LiveUpdateAndUninstallTest.test_brew_provider_live_update_and_uninstall \
139169
tests.LiveUpdateAndUninstallTest.test_pip_provider_live_update_and_uninstall \
@@ -148,6 +178,7 @@ jobs:
148178
if: runner.os == 'Linux'
149179
run: |
150180
source .venv/bin/activate \
181+
&& export PATH="$PNPM_HOME:$PATH" \
151182
&& python -m unittest \
152183
tests.LiveUpdateAndUninstallTest.test_pip_provider_live_update_and_uninstall \
153184
tests.LiveUpdateAndUninstallTest.test_npm_provider_live_update_and_uninstall \
@@ -160,7 +191,7 @@ jobs:
160191
- name: Run root-required live package lifecycle tests on Linux
161192
if: runner.os == 'Linux'
162193
run: |
163-
sudo env "PATH=$PATH:/nix/var/nix/profiles/default/bin" ./.venv/bin/python -m unittest \
194+
sudo env "PATH=$PNPM_HOME:$PATH:/nix/var/nix/profiles/default/bin" ./.venv/bin/python -m unittest \
164195
tests.LiveUpdateAndUninstallTest.test_apt_provider_live_update_and_uninstall \
165196
tests.LiveUpdateAndUninstallTest.test_pyinfra_provider_live_update_and_uninstall \
166197
tests.LiveUpdateAndUninstallTest.test_ansible_provider_live_update_and_uninstall

abx_pkg/binprovider_npm.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def _npm(
188188
bootstrap_pnpm: bool = False,
189189
) -> subprocess.CompletedProcess:
190190
global _CACHED_GLOBAL_NPM_PREFIX
191+
env = os.environ.copy()
191192

192193
npm_abspath = self.INSTALLER_BIN_ABSPATH
193194
if not npm_abspath:
@@ -221,6 +222,19 @@ def _npm(
221222
subcommand, *npm_args = npm_cmd
222223
cmd = npm_cmd
223224
if Path(npm_abspath).name == "pnpm":
225+
pnpm_home = Path(
226+
env.get("PNPM_HOME")
227+
or (
228+
self.npm_prefix / "node_modules/.bin"
229+
if self.npm_prefix
230+
else self.cache_dir / "pnpm-home"
231+
),
232+
)
233+
pnpm_home.mkdir(parents=True, exist_ok=True)
234+
env["PNPM_HOME"] = str(pnpm_home)
235+
path_entries = [entry for entry in env.get("PATH", "").split(":") if entry]
236+
if str(pnpm_home) not in path_entries:
237+
env["PATH"] = ":".join([str(pnpm_home), *path_entries])
224238
cmd = [
225239
{
226240
"install": "add",
@@ -244,6 +258,7 @@ def _npm(
244258
cmd=cmd,
245259
quiet=quiet,
246260
timeout=timeout,
261+
env=env,
247262
)
248263

249264
def setup(self) -> None:

bin/release.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,22 @@ create_release() {
231231
--generate-notes
232232
}
233233

234+
publish_artifacts() {
235+
local version="$1"
236+
local pypi_token="${UV_PUBLISH_TOKEN:-${PYPI_TOKEN:-${PYPI_PAT_SECRET:-}}}"
237+
238+
if [[ -n "${pypi_token}" ]]; then
239+
UV_PUBLISH_TOKEN="${pypi_token}" uv publish --username=__token__ dist/*
240+
elif [[ -n "${GITHUB_ACTIONS:-}" ]]; then
241+
uv publish --trusted-publishing always dist/*
242+
else
243+
echo "Missing PyPI credentials: set UV_PUBLISH_TOKEN or PYPI_TOKEN" >&2
244+
return 1
245+
fi
246+
247+
wait_for_pypi "${PYPI_PACKAGE}" "${version}"
248+
}
249+
234250
main() {
235251
local slug branch version latest relation
236252

@@ -257,9 +273,8 @@ main() {
257273

258274
wait_for_runs "${slug}" push "$(git rev-parse HEAD)" "push"
259275

276+
publish_artifacts "${version}"
260277
create_release "${slug}" "${version}"
261-
wait_for_runs "${slug}" release "$(git rev-parse HEAD)" "release"
262-
wait_for_pypi "${PYPI_PACKAGE}" "${version}"
263278

264279
latest="$(latest_release_version "${slug}")"
265280
relation="$(compare_versions "${latest}" "${version}")"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "abx-pkg"
3-
version = "1.9.17"
3+
version = "1.9.18"
44
description = "System package manager interfaces with Python type hints"
55
authors = [{name = "Nick Sweeting"}, {name = "ArchiveBox"}]
66
requires-python = ">=3.11"

tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ def test_npm_provider_respects_absolute_env_override_over_pnpm(
16081608
BinProvider,
16091609
"INSTALLER_BIN_ABSPATH",
16101610
new_callable=mock.PropertyMock,
1611-
return_value=Path("/usr/local/bin/pip"),
1611+
return_value=Path(sys.executable),
16121612
)
16131613
@mock.patch(
16141614
"abx_pkg.binprovider_pip.PipProvider.load_PATH_from_pip_sitepackages",
@@ -1679,7 +1679,7 @@ def fake_venv_create(path, **kwargs):
16791679
BinProvider,
16801680
"INSTALLER_BIN_ABSPATH",
16811681
new_callable=mock.PropertyMock,
1682-
return_value=Path("/usr/local/bin/pip"),
1682+
return_value=Path(sys.executable),
16831683
)
16841684
@mock.patch(
16851685
"abx_pkg.binprovider_pip.PipProvider.load_PATH_from_pip_sitepackages",
@@ -1742,7 +1742,7 @@ def test_pip_provider_update_uses_install_upgrade(
17421742
BinProvider,
17431743
"INSTALLER_BIN_ABSPATH",
17441744
new_callable=mock.PropertyMock,
1745-
return_value=Path("/usr/local/bin/pip"),
1745+
return_value=Path(sys.executable),
17461746
)
17471747
@mock.patch(
17481748
"abx_pkg.binprovider_pip.PipProvider.load_PATH_from_pip_sitepackages",

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)