Skip to content

Commit 87d8352

Browse files
Decouple PR checks from devcontainer
Co-authored-by: PierreQuinton <PierreQuinton@users.noreply.github.com>
1 parent 45eba36 commit 87d8352

2 files changed

Lines changed: 38 additions & 63 deletions

File tree

.github/workflows/build-devcontainer.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,12 @@ jobs:
2323
- name: Checkout repository
2424
uses: actions/checkout@v6
2525

26-
- name: Compute image path and cache settings
26+
- name: Compute image path
2727
id: image
2828
run: |
2929
repo_lower=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')
3030
echo "name=ghcr.io/$repo_lower/devcontainer:latest" >> $GITHUB_OUTPUT
3131
echo "repo_lower=$repo_lower" >> $GITHUB_OUTPUT
32-
if [ "${{ github.event_name }}" = "pull_request" ]; then
33-
echo "cache-to=" >> $GITHUB_OUTPUT
34-
else
35-
echo "cache-to=type=registry,ref=ghcr.io/$repo_lower/devcontainer:cache,mode=max" >> $GITHUB_OUTPUT
36-
fi
3732
3833
- name: Log in to GitHub Container Registry
3934
if: github.event_name != 'pull_request'
@@ -46,14 +41,26 @@ jobs:
4641
- name: Set up Docker Buildx
4742
uses: docker/setup-buildx-action@v3
4843

49-
- name: Build and push devcontainer image
44+
- name: Build devcontainer image (PR)
45+
if: github.event_name == 'pull_request'
5046
uses: docker/build-push-action@v6
5147
with:
5248
context: .
5349
file: .devcontainer/Dockerfile
54-
push: ${{ github.event_name != 'pull_request' }}
50+
push: false
51+
tags: ${{ steps.image.outputs.name }}
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max
54+
55+
- name: Build and push devcontainer image (main)
56+
if: github.event_name != 'pull_request'
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: .
60+
file: .devcontainer/Dockerfile
61+
push: true
5562
tags: ${{ steps.image.outputs.name }}
5663
cache-from: |
5764
type=registry,ref=ghcr.io/${{ steps.image.outputs.repo_lower }}/devcontainer:cache
5865
type=registry,ref=ghcr.io/${{ steps.image.outputs.repo_lower }}/devcontainer:latest
59-
cache-to: ${{ steps.image.outputs.cache-to }}
66+
cache-to: type=registry,ref=ghcr.io/${{ steps.image.outputs.repo_lower }}/devcontainer:cache,mode=max

.github/workflows/checks.yml

Lines changed: 22 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -67,85 +67,53 @@ jobs:
6767
with:
6868
token: ${{ secrets.CODECOV_TOKEN }}
6969

70-
build-devcontainer:
71-
name: Build devcontainer image
72-
runs-on: ubuntu-latest
73-
permissions:
74-
packages: write
75-
outputs:
76-
image: ${{ steps.image.outputs.name }}
77-
steps:
78-
- name: Checkout repository
79-
uses: actions/checkout@v6
80-
81-
- name: Log in to GitHub Container Registry
82-
uses: docker/login-action@v3
83-
with:
84-
registry: ghcr.io
85-
username: ${{ github.actor }}
86-
password: ${{ secrets.GITHUB_TOKEN }}
87-
88-
- name: Set up Docker Buildx
89-
uses: docker/setup-buildx-action@v3
90-
91-
- name: Compute image path
92-
id: image
93-
run: |
94-
repo_lower=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')
95-
echo "name=ghcr.io/$repo_lower/devcontainer:${{ github.sha }}" >> $GITHUB_OUTPUT
96-
echo "cache-ref=ghcr.io/$repo_lower/devcontainer:cache" >> $GITHUB_OUTPUT
97-
98-
- name: Build and push devcontainer image
99-
uses: docker/build-push-action@v6
100-
with:
101-
context: .
102-
file: .devcontainer/Dockerfile
103-
push: true
104-
tags: ${{ steps.image.outputs.name }}
105-
cache-from: |
106-
type=registry,ref=${{ steps.image.outputs.cache-ref }}
107-
type=registry,ref=ghcr.io/${{ github.repository_owner }}/devcontainer:latest
108-
cache-to: type=registry,ref=${{ steps.image.outputs.cache-ref }},mode=max
109-
11070
build-doc:
11171
name: Build and test documentation
112-
needs: build-devcontainer
11372
runs-on: ubuntu-latest
114-
container:
115-
image: ${{ needs.build-devcontainer.outputs.image }}
11673
steps:
11774
- name: Checkout repository
11875
uses: actions/checkout@v6
11976

120-
- name: Sync project installation
121-
run: uv pip install --python /opt/venv/bin/python -e '.[full]' --group doc
77+
- name: Set up uv
78+
uses: astral-sh/setup-uv@v7
79+
with:
80+
python-version: '3.14'
81+
82+
- uses: ./.github/actions/install-deps
83+
with:
84+
options: full
85+
groups: doc
12286

12387
- name: Build Documentation
12488
working-directory: docs
125-
run: make dirhtml
89+
run: uv run make dirhtml
12690

12791
- name: Test Documentation
12892
working-directory: docs
129-
run: make doctest
93+
run: uv run make doctest
13094

13195
code-quality:
13296
name: Code quality (ty and pre-commit hooks)
133-
needs: build-devcontainer
13497
runs-on: ubuntu-latest
135-
container:
136-
image: ${{ needs.build-devcontainer.outputs.image }}
13798
steps:
13899
- name: Checkout repository
139100
uses: actions/checkout@v6
140101

141-
- name: Sync project installation
142-
run: uv pip install --python /opt/venv/bin/python -e '.[full]' --group check --group test --group plot
102+
- name: Set up uv
103+
uses: astral-sh/setup-uv@v7
104+
with:
105+
python-version: '3.14'
106+
107+
- uses: ./.github/actions/install-deps
108+
with:
109+
options: full
110+
groups: check test plot
143111

144112
- name: Configure git safe directory
145113
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
146114

147115
- name: Run pre-commit hooks
148-
run: pre-commit run --all-files
116+
run: uv run pre-commit run --all-files
149117

150118
- name: Run ty
151-
run: ty check --output-format=github
119+
run: uv run ty check --output-format=github

0 commit comments

Comments
 (0)