Skip to content

Commit 327879b

Browse files
authored
Fix credentials not passed or configured the CI workflow (#286)
- **Replace the old `setup-git-user` step with `gh-action-setup-git`** - **Add a `gh-action-setup-git` step to every job doing a checkout** - **ci: Pass git credentials to the `test-installation` job** - **Improve spacing of the test-installation job** - **Add migration steps to the migration script** - **Apply the migration script to this repository** - **Remove the TODOs from the migration** - **Update release notes** Fixes #278.
2 parents eb23fa1 + 6195bc7 commit 327879b

File tree

21 files changed

+562
-56
lines changed

21 files changed

+562
-56
lines changed

.github/containers/test-installation/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ RUN apt-get update -y && \
1414
python -m pip install --upgrade --no-cache-dir pip
1515

1616
COPY dist dist
17-
RUN pip install dist/*.whl && \
18-
rm -rf dist
17+
# This git-credentials file is made available by the GitHub ci.yaml workflow
18+
COPY git-credentials /root/.git-credentials
19+
RUN git config --global credential.helper store && \
20+
pip install dist/*.whl && \
21+
rm -rf dist /root/.git-credentials

.github/workflows/ci.yaml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ jobs:
4141
runs-on: ${{ matrix.os }}
4242

4343
steps:
44+
- name: Setup Git
45+
uses: frequenz-floss/[email protected]
46+
4447
- name: Print environment (debug)
4548
run: env
4649

@@ -119,6 +122,9 @@ jobs:
119122
runs-on: ${{ matrix.os }}
120123

121124
steps:
125+
- name: Setup Git
126+
uses: frequenz-floss/[email protected]
127+
122128
- name: Fetch sources
123129
uses: actions/checkout@v4
124130

@@ -220,6 +226,9 @@ jobs:
220226
name: Build distribution packages
221227
runs-on: ubuntu-20.04
222228
steps:
229+
- name: Setup Git
230+
uses: frequenz-floss/[email protected]
231+
223232
- name: Fetch sources
224233
uses: actions/checkout@v4
225234
with:
@@ -252,17 +261,29 @@ jobs:
252261
needs: ["build"]
253262
runs-on: ubuntu-20.04
254263
steps:
264+
- name: Setup Git
265+
uses: frequenz-floss/[email protected]
266+
255267
- name: Fetch sources
256268
uses: actions/checkout@v4
269+
257270
- name: Download package
258271
uses: actions/download-artifact@v4
259272
with:
260273
name: dist-packages
261274
path: dist
275+
276+
- name: Make Git credentials available to docker
277+
run: |
278+
touch ~/.git-credentials # Ensure the file exists
279+
cp ~/.git-credentials git-credentials || true
280+
262281
- name: Set up QEMU
263282
uses: docker/setup-qemu-action@v3
283+
264284
- name: Set up docker-buildx
265285
uses: docker/setup-buildx-action@v3
286+
266287
- name: Test Installation
267288
uses: docker/build-push-action@v6
268289
with:
@@ -277,14 +298,14 @@ jobs:
277298
if: github.event_name != 'push'
278299
runs-on: ubuntu-20.04
279300
steps:
301+
- name: Setup Git
302+
uses: frequenz-floss/[email protected]
303+
280304
- name: Fetch sources
281305
uses: actions/checkout@v4
282306
with:
283307
submodules: true
284308

285-
- name: Setup Git user and e-mail
286-
uses: frequenz-floss/setup-git-user@v2
287-
288309
- name: Set up Python
289310
uses: actions/setup-python@v5
290311
with:
@@ -319,14 +340,14 @@ jobs:
319340
permissions:
320341
contents: write
321342
steps:
343+
- name: Setup Git
344+
uses: frequenz-floss/[email protected]
345+
322346
- name: Fetch sources
323347
uses: actions/checkout@v4
324348
with:
325349
submodules: true
326350

327-
- name: Setup Git user and e-mail
328-
uses: frequenz-floss/setup-git-user@v2
329-
330351
- name: Set up Python
331352
uses: actions/setup-python@v5
332353
with:

RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@
5252

5353
- Fixed a bug where the pip cache post action fails in the CI workflow because of permissions issues.
5454
- Make the `nox-cross-arch-all` job fail if any `nox-cross-arch` matrix job fails.
55+
- Fix credentials not being passed to the `test-installation` job in the CI workflow.
56+
- Make sure credentials are configured for all jobs that check out the repository in the CI workflow.

cookiecutter/migrate.sh

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,152 @@ echo "========================================================================"
9494
echo "Using symlink aliases in 'mkdocs.yml'"
9595
sed -i "s|alias_type: redirect|alias_type: symlink|" mkdocs.yml
9696

97+
echo "========================================================================"
98+
99+
echo "Fixing credentials not being properly passed in '.github/workflows/ci.yaml'"
100+
patch --merge -p1 <<'EOF'
101+
diff --git a/.github/containers/test-installation/Dockerfile b/.github/containers/test-installation/Dockerfile
102+
index 2494545..ac3de24 100644
103+
--- a/.github/containers/test-installation/Dockerfile
104+
+++ b/.github/containers/test-installation/Dockerfile
105+
@@ -14,5 +14,8 @@ RUN apt-get update -y && \
106+
python -m pip install --upgrade --no-cache-dir pip
107+
108+
COPY dist dist
109+
-RUN pip install dist/*.whl && \
110+
- rm -rf dist
111+
+# This git-credentials file is made available by the GitHub ci.yaml workflow
112+
+COPY git-credentials /root/.git-credentials
113+
+RUN git config --global credential.helper store && \
114+
+ pip install dist/*.whl && \
115+
+ rm -rf dist /root/.git-credentials
116+
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
117+
index 8062a61..67000f1 100644
118+
--- a/.github/workflows/ci.yaml
119+
+++ b/.github/workflows/ci.yaml
120+
@@ -41,6 +41,13 @@ jobs:
121+
runs-on: ${{ matrix.os }}
122+
123+
steps:
124+
+ - name: Setup Git
125+
+ uses: frequenz-floss/[email protected]
126+
+ # TODO(cookiecutter): Uncomment this for projects with private dependencies
127+
+ # with:
128+
+ # username: ${{ secrets.GIT_USER }}
129+
+ # password: ${{ secrets.GIT_PASS }}
130+
+
131+
- name: Print environment (debug)
132+
run: env
133+
134+
@@ -119,6 +126,13 @@ jobs:
135+
runs-on: ${{ matrix.os }}
136+
137+
steps:
138+
+ - name: Setup Git
139+
+ uses: frequenz-floss/[email protected]
140+
+ # TODO(cookiecutter): Uncomment this for projects with private dependencies
141+
+ # with:
142+
+ # username: ${{ secrets.GIT_USER }}
143+
+ # password: ${{ secrets.GIT_PASS }}
144+
+
145+
- name: Fetch sources
146+
uses: actions/checkout@v4
147+
148+
@@ -220,6 +234,13 @@ jobs:
149+
name: Build distribution packages
150+
runs-on: ubuntu-20.04
151+
steps:
152+
+ - name: Setup Git
153+
+ uses: frequenz-floss/[email protected]
154+
+ # TODO(cookiecutter): Uncomment this for projects with private dependencies
155+
+ # with:
156+
+ # username: ${{ secrets.GIT_USER }}
157+
+ # password: ${{ secrets.GIT_PASS }}
158+
+
159+
- name: Fetch sources
160+
uses: actions/checkout@v4
161+
with:
162+
@@ -252,17 +273,31 @@ jobs:
163+
needs: ["build"]
164+
runs-on: ubuntu-20.04
165+
steps:
166+
+ - name: Setup Git
167+
+ uses: frequenz-floss/[email protected]
168+
+ # TODO(cookiecutter): Uncomment this for projects with private dependencies
169+
+ # with:
170+
+ # username: ${{ secrets.GIT_USER }}
171+
+ # password: ${{ secrets.GIT_PASS }}
172+
+
173+
- name: Fetch sources
174+
uses: actions/checkout@v4
175+
+
176+
- name: Download package
177+
uses: actions/download-artifact@v4
178+
with:
179+
name: dist-packages
180+
path: dist
181+
+
182+
+ - name: Make Git credentials available to docker
183+
run: |
184+
touch ~/.git-credentials # Ensure the file exists
185+
+ cp ~/.git-credentials git-credentials || true
186+
+
187+
- name: Set up QEMU
188+
uses: docker/setup-qemu-action@v3
189+
+
190+
- name: Set up docker-buildx
191+
uses: docker/setup-buildx-action@v3
192+
+
193+
- name: Test Installation
194+
uses: docker/build-push-action@v6
195+
with:
196+
@@ -277,14 +312,18 @@ jobs:
197+
if: github.event_name != 'push'
198+
runs-on: ubuntu-20.04
199+
steps:
200+
+ - name: Setup Git
201+
+ uses: frequenz-floss/[email protected]
202+
+ # TODO(cookiecutter): Uncomment this for projects with private dependencies
203+
+ # with:
204+
+ # username: ${{ secrets.GIT_USER }}
205+
+ # password: ${{ secrets.GIT_PASS }}
206+
+
207+
- name: Fetch sources
208+
uses: actions/checkout@v4
209+
with:
210+
submodules: true
211+
212+
- - name: Setup Git user and e-mail
213+
- uses: frequenz-floss/setup-git-user@v2
214+
-
215+
- name: Set up Python
216+
uses: actions/setup-python@v5
217+
with:
218+
@@ -319,14 +358,18 @@ jobs:
219+
permissions:
220+
contents: write
221+
steps:
222+
+ - name: Setup Git
223+
+ uses: frequenz-floss/[email protected]
224+
+ # TODO(cookiecutter): Uncomment this for projects with private dependencies
225+
+ # with:
226+
+ # username: ${{ secrets.GIT_USER }}
227+
+ # password: ${{ secrets.GIT_PASS }}
228+
+
229+
- name: Fetch sources
230+
uses: actions/checkout@v4
231+
with:
232+
submodules: true
233+
234+
- - name: Setup Git user and e-mail
235+
- uses: frequenz-floss/setup-git-user@v2
236+
-
237+
- name: Set up Python
238+
uses: actions/setup-python@v5
239+
with:
240+
EOF
241+
manual_step "Please make sure to remove or uncomment the options to the 'gh-action-setup-git' action in the '.github/workflows/ci.yaml'"
242+
grep -n "TODO(cookiecutter)" -- .github/workflows/ci.yaml .github/containers/test-installation/Dockerfile
243+
97244
# Add a separation line like this one after each migration step.
98245
echo "========================================================================"

cookiecutter/{{cookiecutter.github_repo_name}}/.github/containers/test-installation/Dockerfile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ RUN apt-get update -y && \
1515
python -m pip install --upgrade --no-cache-dir pip
1616

1717
COPY dist dist
18-
RUN pip install dist/*.whl && \
19-
rm -rf dist
18+
# This git-credentials file is made available by the GitHub ci.yaml workflow
19+
COPY git-credentials /root/.git-credentials
20+
RUN git config --global credential.helper store && \
21+
pip install dist/*.whl && \
22+
rm -rf dist /root/.git-credentials
2023
{%- endraw %}

0 commit comments

Comments
 (0)