Skip to content

Commit f2c66dd

Browse files
committed
Updating github-config
1 parent 887f418 commit f2c66dd

File tree

2 files changed

+85
-28
lines changed

2 files changed

+85
-28
lines changed

.github/workflows/test-pull-request.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
runs-on: ubuntu-22.04
8383
steps:
8484
- name: Upload Artifact
85-
uses: actions/upload-artifact@v3
85+
uses: actions/upload-artifact@v4
8686
with:
8787
name: event-payload
8888
path: ${{ github.event_path }}

.github/workflows/update-dependencies-from-metadata.yml

+84-27
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
outputs:
1313
metadata-filepath: ${{ steps.retrieve.outputs.metadata-filepath }}
1414
metadata-json: ${{ steps.retrieve.outputs.metadata-json }}
15+
# from-source-metadata-filepath is the path to a file containing a subset
16+
# of metadata-json entries for NON-compiled dependencies
17+
from-source-metadata-filepath: ${{ steps.retrieve.outputs.from-source-metadata-filepath }}
1518
# compilation-json is a subset of metadata-json entries which are missing
1619
# a `checksum` and `uri`
1720
compilation-json: ${{ steps.retrieve.outputs.compilation-json }}
@@ -20,17 +23,21 @@ jobs:
2023
compilation-length: ${{ steps.retrieve.outputs.compilation-length }}
2124
steps:
2225
- name: Check out code
23-
uses: actions/checkout@v3
26+
uses: actions/checkout@v4
2427

2528
- name: Setup Go
26-
uses: actions/setup-go@v3
29+
uses: actions/setup-go@v5
2730
with:
2831
go-version: 'stable'
2932

3033
- name: Run Retrieve
3134
id: retrieve
3235
working-directory: dependency
3336
run: |
37+
#!/usr/bin/env bash
38+
set -euo pipefail
39+
shopt -s inherit_errexit
40+
3441
OUTPUT="/tmp/metadata.json"
3542
3643
make retrieve \
@@ -44,6 +51,9 @@ jobs:
4451
4552
compilation=$(echo $content | jq -r 'map(select(.checksum == null and .uri == null))'?)
4653
complength=$(echo $compilation | jq -r '. | length')
54+
echo $content | jq -r 'map(select(.checksum != null and .uri != null))'? > "/tmp/from-source-metadata.json"
55+
echo "from-source-metadata-filepath=/tmp/from-source-metadata.json" >> "$GITHUB_OUTPUT"
56+
4757
4858
delimiter="$(uuidgen)"
4959
echo "metadata-filepath=${OUTPUT}" >> "$GITHUB_OUTPUT"
@@ -55,11 +65,17 @@ jobs:
5565
5666
5767
- name: Upload `${{ steps.retrieve.outputs.metadata-filepath }}`
58-
uses: actions/upload-artifact@v3
68+
uses: actions/upload-artifact@v4
5969
with:
6070
name: metadata.json
6171
path: ${{ steps.retrieve.outputs.metadata-filepath }}
6272
73+
- name: Upload `${{ steps.retrieve.outputs.from-source-metadata-filepath }}`
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: from-source-metadata.json
77+
path: ${{ steps.retrieve.outputs.from-source-metadata-filepath }}
78+
6379
# Check if there is buildpack-provided compilation code and testing code
6480
# Optional compilation code expected at: <buildpack>/dependency/actions/compile/
6581
# Optional testing code expected at: <buildpack>/dependency/test/
@@ -71,7 +87,7 @@ jobs:
7187
runs-on: ubuntu-latest
7288
steps:
7389
- name: Check out code
74-
uses: actions/checkout@v3
90+
uses: actions/checkout@v4
7591
7692
- name: Has Compilation Action?
7793
id: compile-check
@@ -106,19 +122,22 @@ jobs:
106122
runs-on: ubuntu-latest
107123
steps:
108124
- name: Check out code
109-
uses: actions/checkout@v3
125+
uses: actions/checkout@v4
110126
111127
- name: Make Temporary Artifact Directory
112128
id: make-outputdir
113-
run: |
114-
echo "outputdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
129+
run: echo "outputdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
115130
116131
# Download the tarball for testing if:
117132
# (1) dependency testing code is present in the buildpack directory
118133
# (2) URI in metadata.json is available
119134
- name: Download upstream tarball (if not compiled)
120135
if: ${{ matrix.includes.uri != '' && needs.get-compile-and-test.outputs.should-test == 'true' }}
121136
run: |
137+
#!/usr/bin/env bash
138+
set -euo pipefail
139+
shopt -s inherit_errexit
140+
122141
curl ${{ matrix.includes.uri }} \
123142
--fail-with-body \
124143
--show-error \
@@ -135,7 +154,6 @@ jobs:
135154
make test \
136155
version="${{ matrix.includes.version }}" \
137156
tarballPath="${{ steps.make-outputdir.outputs.outputdir }}/*.tgz"
138-
139157
compile:
140158
name: Compile and Test Dependency
141159
needs:
@@ -153,7 +171,7 @@ jobs:
153171
runs-on: ubuntu-latest
154172
steps:
155173
- name: Check out code
156-
uses: actions/checkout@v3
174+
uses: actions/checkout@v4
157175
158176
- name: Make Temporary Artifact Directory
159177
id: make-outputdir
@@ -175,7 +193,7 @@ jobs:
175193
176194
# If compiled, upload the tarball and checksum file for usage in the Update metadata job
177195
- name: Upload workflow asset
178-
uses: actions/upload-artifact@v3
196+
uses: actions/upload-artifact@v4
179197
if: ${{ needs.get-compile-and-test.outputs.should-compile && matrix.includes.checksum == '' && matrix.includes.uri == '' }}
180198
with:
181199
name: '${{ needs.retrieve.outputs.id }}-${{ matrix.includes.version }}-${{ matrix.includes.target }}'
@@ -187,6 +205,10 @@ jobs:
187205
working-directory: dependency
188206
if: ${{ needs.get-compile-and-test.outputs.should-test == 'true' }}
189207
run: |
208+
#!/usr/bin/env bash
209+
set -euo pipefail
210+
shopt -s inherit_errexit
211+
190212
make test \
191213
version="${{ matrix.includes.version }}" \
192214
tarballPath="${{ steps.make-outputdir.outputs.outputdir }}/*.tgz"
@@ -201,23 +223,24 @@ jobs:
201223
strategy:
202224
matrix:
203225
includes: ${{ fromJSON(needs.retrieve.outputs.compilation-json) }}
204-
# Run metadata update step sequentially so that metadata.json can be
205-
# modified for each version
206-
max-parallel: 1
207226
if: ${{ needs.retrieve.outputs.compilation-length > 0 && needs.get-compile-and-test.outputs.should-compile == 'true' }}
208227
runs-on: ubuntu-latest
209228
steps:
210229
- name: Check out code
211-
uses: actions/checkout@v3
230+
uses: actions/checkout@v4
212231
213232
- name: Download artifact files
214-
uses: actions/download-artifact@v3
233+
uses: actions/download-artifact@v4
215234
with:
216235
name: '${{ needs.retrieve.outputs.id }}-${{ matrix.includes.version }}-${{ matrix.includes.target }}'
217236
218237
- name: Get artifact file name
219238
id: get-file-names
220239
run: |
240+
#!/usr/bin/env bash
241+
set -euo pipefail
242+
shopt -s inherit_errexit
243+
221244
echo "artifact-file=$(basename ./*.tgz)" >> "$GITHUB_OUTPUT"
222245
echo "checksum-file=$(basename ./*.tgz.checksum)" >> "$GITHUB_OUTPUT"
223246
@@ -241,10 +264,23 @@ jobs:
241264
run: echo "checksum=$(cat ${{ steps.get-file-names.outputs.checksum-file }})" >> "$GITHUB_OUTPUT"
242265
243266
- name: Download metadata.json
244-
uses: actions/download-artifact@v3
267+
uses: actions/download-artifact@v4
245268
with:
246269
name: metadata.json
247270
271+
# Create target/version specific metadata files
272+
# Due to limitations with the upload action, we can no longer modify/upload the same metadata file
273+
- name: Write dependency-specific metadata to new file
274+
id: dependency-metadata
275+
run: |
276+
#!/usr/bin/env bash
277+
set -euo pipefail
278+
shopt -s inherit_errexit
279+
280+
metadata_file_name="${{ matrix.includes.target }}-${{ matrix.includes.version }}-metadata-file.json"
281+
cat metadata.json | jq -r ['.[] | select( .version == "${{ matrix.includes.version }}" and .target == "${{ matrix.includes.target }}")'] > $metadata_file_name
282+
echo "file=$(echo $metadata_file_name)" >> "$GITHUB_OUTPUT"
283+
248284
- name: Update `checksum` and `uri` in metadata for ${{ matrix.includes.target }} ${{ matrix.includes.version }}
249285
if: ${{ matrix.includes.checksum == '' && matrix.includes.uri == '' }}
250286
uses: paketo-buildpacks/github-config/actions/dependency/update-metadata-json@main
@@ -253,13 +289,13 @@ jobs:
253289
target: ${{ matrix.includes.target }}
254290
checksum: ${{ steps.get-checksum.outputs.checksum }}
255291
uri: ${{ steps.upload.outputs.dependency-uri }}
256-
file: "metadata.json"
292+
file: ${{ steps.dependency-metadata.outputs.file }}
257293
258294
- name: Upload modified metadata
259-
uses: actions/upload-artifact@v3
295+
uses: actions/upload-artifact@v4
260296
with:
261-
name: "metadata.json"
262-
path: "metadata.json"
297+
name: ${{ steps.dependency-metadata.outputs.file }}
298+
path: ${{ steps.dependency-metadata.outputs.file }}
263299
264300
assemble:
265301
name: Update buildpack.toml
@@ -277,7 +313,7 @@ jobs:
277313
runs-on: ubuntu-latest
278314
steps:
279315
- name: Check out code
280-
uses: actions/checkout@v3
316+
uses: actions/checkout@v4
281317
282318
- name: Checkout Branch
283319
uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main
@@ -286,14 +322,35 @@ jobs:
286322
287323
- name: Make Temporary Artifact Directory
288324
id: make-outputdir
289-
run: |
290-
echo "outputdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
325+
run: echo "outputdir=$(mktemp -d)" >> "$GITHUB_OUTPUT"
291326
292-
- name: Download metadata.json
293-
uses: actions/download-artifact@v3
327+
328+
# Metadata file for the non-compiled dependencies, if there are any
329+
- name: Download metadata.json file
330+
uses: actions/download-artifact@v4
294331
with:
295-
name: metadata.json
296-
path: "${{ steps.make-outputdir.outputs.outputdir }}"
332+
path: "${{ steps.make-outputdir.outputs.outputdir }}/metadata-files"
333+
pattern: "from-source-metadata.json"
334+
merge-multiple: true
335+
336+
# If we compiled the dependency, and updated the metadata:
337+
# Download each metadata file, and combine them into one
338+
- name: Download individual metadata-file.json file(s)
339+
if: ${{ needs.update-metadata.result == 'success' }}
340+
uses: actions/download-artifact@v4
341+
with:
342+
path: "${{ steps.make-outputdir.outputs.outputdir }}/metadata-files"
343+
pattern: "*metadata-file.json"
344+
merge-multiple: true
345+
- name: Display Metadata Files
346+
run: ls "${{ steps.make-outputdir.outputs.outputdir }}/metadata-files"
347+
- name: Combine Metadata Files
348+
run: |
349+
#!/usr/bin/env bash
350+
set -euo pipefail
351+
shopt -s inherit_errexit
352+
353+
jq -s 'add' ${{ steps.make-outputdir.outputs.outputdir }}/metadata-files/* > "${{ steps.make-outputdir.outputs.outputdir }}/metadata.json"
297354
298355
- name: Update dependencies from metadata.json
299356
id: update

0 commit comments

Comments
 (0)