Skip to content

Commit fc898b2

Browse files
CI: separate tools and plugin release steps (#248)
Currently, tools releases (which include please_pex) are blocked if the tests fail when built by the stable please_pex release, which prevents new versions of please_pex from being released in the event that external factors (e.g. changes on the CI platform) cause please_pex to stop working. Break this cyclic dependency by only making tools releases contingent on the tests passing when built by the in-repo version of please_pex, and only make plugin releases contingent on the tests passing when built by the version of please_pex downloaded by `//tools:please_pex`. This allows us to fix problems with please_pex, get a new version released, and use that version in the plugin without having to temporarily disable any tests in the workflow.
1 parent 4bf549f commit fc898b2

File tree

4 files changed

+93
-67
lines changed

4 files changed

+93
-67
lines changed

.github/workflows/plugin.yaml

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,51 @@
1-
name: Python rules
2-
on: [push, pull_request]
1+
name: Plugin
2+
on:
3+
- push
4+
- pull_request
35
jobs:
6+
test-please_pex:
7+
name: Test (Python ${{ matrix.python }}, in-repo please_pex)
8+
uses: ./.github/workflows/plugin_test.yaml
9+
with:
10+
runner: ubuntu-latest
11+
python: ${{ matrix.python }}
12+
please_pex_from_repo: true
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python:
17+
- '3.9'
18+
- '3.10'
19+
- '3.11'
20+
- '3.12'
21+
- '3.13'
422
test:
5-
name: Test (Python ${{ matrix.python-version }}, ${{ matrix.pex-tool }} pex tool)
6-
runs-on: ubuntu-latest
23+
name: Test (Python ${{ matrix.python }}, stable please_pex release)
24+
uses: ./.github/workflows/plugin_test.yaml
25+
with:
26+
runner: ubuntu-latest
27+
python: ${{ matrix.python }}
28+
please_pex_from_repo: false
729
strategy:
830
fail-fast: false
931
matrix:
10-
python-version:
32+
python:
1133
- '3.9'
1234
- '3.10'
1335
- '3.11'
1436
- '3.12'
1537
- '3.13'
16-
pex-tool:
17-
- default
18-
- in-repo
19-
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v5
22-
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v6
24-
with:
25-
python-version: ${{ matrix.python-version }}
26-
- name: Use this Python in Please build environments
27-
run: |
28-
echo "CI_PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
29-
echo "PLZ_ARGS=-o plugin.python.defaultinterpreter:$(which python3) -o build.passenv:CI_PYTHON_VERSION" >> $GITHUB_ENV
30-
- name: Build and use in-repo pex tool
31-
if: matrix.pex-tool == 'in-repo'
32-
run: |
33-
./pleasew build //tools/please_pex
34-
cp $(./pleasew query outputs //tools/please_pex) $HOME/please_pex
35-
echo "PLZ_ARGS="$(grep ^PLZ_ARGS= $GITHUB_ENV | cut -d= -f2-)" -o plugin.python.pextool:$HOME/please_pex" >> $GITHUB_ENV
36-
- name: Run tests
37-
run: ./pleasew test --log_file plz-out/log/test.log -e e2e
38-
- name: Run e2e test
39-
run: ./pleasew test --log_file plz-out/log/e2e.log -i e2e
40-
- name: Archive logs
41-
if: always()
42-
uses: actions/upload-artifact@v4
43-
with:
44-
name: logs-${{ matrix.python-version }}-please_pex-${{ matrix.pex-tool }}
45-
path: plz-out/log
46-
release:
47-
needs: [test]
38+
release-tools:
39+
name: Release tools
40+
if: github.ref == 'refs/heads/master'
41+
needs:
42+
- test-please_pex
4843
runs-on: ubuntu-latest
49-
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/v1'
5044
steps:
51-
- name: Checkout code
45+
- name: Check out code
5246
uses: actions/checkout@v5
53-
- name: Build
47+
- name: Build tools
5448
run: ./pleasew build //package:release_files
55-
- name: Release
56-
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
uses: thought-machine/release-action@master
5949
- name: Release tools
6050
env:
6151
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -65,3 +55,16 @@ jobs:
6555
version-file: tools/VERSION
6656
change-log-file: tools/ChangeLog
6757
release-prefix: tools
58+
release-plugin:
59+
name: Release plugin
60+
if: github.ref == 'refs/heads/master'
61+
needs:
62+
- test
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Check out code
66+
uses: actions/checkout@v5
67+
- name: Release plugin
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
uses: thought-machine/release-action@master

.github/workflows/plugin_test.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
runner:
5+
description: "The GitHub runner type on which this workflow should run."
6+
required: true
7+
type: string
8+
python:
9+
description: "The Python version to configure the plugin to use. Must be a value of python-version recognised by the actions/setup-python action."
10+
required: true
11+
type: string
12+
please_pex_from_repo:
13+
description: "Whether to build please_pex from source and use that as the plugin's please_pex tool (true), or use the existing binary version of please_pex downloaded by //tools:please_pex (false)."
14+
required: false
15+
type: boolean
16+
default: false
17+
jobs:
18+
test:
19+
name: Run tests
20+
runs-on: ${{ inputs.runner }}
21+
steps:
22+
- name: Install Python in CI environment
23+
id: python
24+
uses: actions/setup-python@v6
25+
with:
26+
python-version: ${{ inputs.python }}
27+
update-environment: false
28+
- name: Check out code
29+
uses: actions/checkout@v5
30+
- name: Configure plugin's default Python interpreter
31+
run: |
32+
echo "PLZ_ARGS=-o plugin.python.defaultinterpreter:${{ steps.python.outputs.python-path }}" >> $GITHUB_ENV
33+
- name: Build please_pex
34+
if: inputs.please_pex_from_repo
35+
# This copies the please_pex binary into the runner user's home directory so it persists across steps.
36+
run: |
37+
./pleasew build //tools/please_pex
38+
cp $(./pleasew query outputs //tools/please_pex) $HOME/please_pex
39+
echo "PLZ_ARGS="$(grep ^PLZ_ARGS= $GITHUB_ENV | cut -d= -f2-)" -o plugin.python.pextool:$HOME/please_pex" >> $GITHUB_ENV
40+
- name: Run tests
41+
run: ./pleasew test --keep_going --log_file plz-out/log/test.log
42+
- name: Archive logs
43+
uses: actions/upload-artifact@v4
44+
with:
45+
name: logs-python_${{ inputs.python }}-please_pex_${{ inputs.please_pex_from_repo && 'repo' || 'stable' }}
46+
path: plz-out/log

test/BUILD

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,6 @@ python_test(
176176
],
177177
)
178178

179-
# This test need only run in the GitHub Actions workflow - it is skipped outside this environment.
180-
python_test(
181-
name = "ci_test",
182-
srcs = ["ci_test.py"],
183-
)
184-
185179
python_test(
186180
name = "interpreter_not_included_test",
187181
srcs = ["interpreter_not_included_test.py"],

test/ci_test.py

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

0 commit comments

Comments
 (0)