Skip to content

Commit 9c784d8

Browse files
[skip-changelog] Use a matrix to create parallel builds for each OS (#1883)
* Use a matrix create parallel builds for each os Using a matrix to run each build task greatly improves performances, since they can all start concurrently. The finishing time of the job will be equal to the one of the longer task to build, instead of being the sum of each individual task's finishing time. * Calculate checksums during release creation Checksums of the output files where previously calculated during the initial creation of the artifacts, during the notarization process and, finally, at the release creation's step. The whole process has been simplified and checksums are now computed only during the creation of the release. * Set condition to create changelog once The changelog is the same for each OS. It does not make sense to generate it more than once. * Disable s3 push for testing * Upload nightly artifacts for testing * Fix linux_arm_6 typo * Stop uploading nigthly artifacts * Enable s3 pushing * Upload build artifacts separately Previously, the different builds were firstly uploaded using a single artifact, which was then downloaded to create different ones and eventually deleted. Now, since builds are created concurrently, the same matrix can be used to directly upload an artifact for each build. It's necessary to use a second job to calculate the checksum related to each build and save them all in a single .txt file.
1 parent e404a3b commit 9c784d8

File tree

4 files changed

+106
-106
lines changed

4 files changed

+106
-106
lines changed

Diff for: .github/workflows/publish-go-nightly-task.yml

+21-18
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ jobs:
2222
create-nightly-artifacts:
2323
runs-on: ubuntu-latest
2424

25+
strategy:
26+
matrix:
27+
os:
28+
- Windows_32bit
29+
- Windows_64bit
30+
- Linux_32bit
31+
- Linux_64bit
32+
- Linux_ARMv6
33+
- Linux_ARMv7
34+
- Linux_ARM64
35+
- macOS_64bit
36+
- macOS_ARM64
37+
2538
steps:
2639
- name: Checkout repository
2740
uses: actions/checkout@v3
@@ -35,7 +48,7 @@ jobs:
3548
- name: Build
3649
env:
3750
NIGHTLY: true
38-
run: task dist:all
51+
run: task dist:${{ matrix.os }}
3952

4053
- name: Upload artifacts
4154
uses: actions/upload-artifact@v3
@@ -127,14 +140,10 @@ jobs:
127140
run: |
128141
gon "${{ env.GON_CONFIG_PATH }}"
129142
130-
- name: Re-package binary and output checksum
143+
- name: Re-package binary
131144
id: re-package
132145
working-directory: ${{ env.DIST_DIR }}
133-
# This step performs the following:
134-
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
135-
# 2. Recalculate package checksum
136-
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
137-
# (it cannot be done there because of workflow job parallelization)
146+
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
138147
run: |
139148
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
140149
# so we need to add execution permission back until the action is made to do this.
@@ -144,11 +153,9 @@ jobs:
144153
tar -czvf "$PACKAGE_FILENAME" \
145154
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
146155
-C ../../ LICENSE.txt
147-
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
148156
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
149-
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
150157
151-
- name: Upload artifacts
158+
- name: Upload artifact
152159
uses: actions/upload-artifact@v3
153160
with:
154161
if-no-files-found: error
@@ -166,15 +173,11 @@ jobs:
166173
name: ${{ env.ARTIFACT_NAME }}
167174
path: ${{ env.DIST_DIR }}
168175

169-
- name: Update checksum
176+
- name: Output checksum
177+
working-directory: ${{ env.DIST_DIR}}
170178
run: |
171-
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
172-
for checksum_line in "${checksum_lines[@]}"
173-
do
174-
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
175-
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
176-
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
177-
done
179+
TAG="nightly-$(date -u +"%Y%m%d")"
180+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* >> ${TAG}-checksums.txt
178181
179182
- name: Upload release files on Arduino downloads servers
180183
uses: docker://plugins/s3

Diff for: .github/workflows/publish-go-tester-task.yml

+61-46
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ on:
2424
repository_dispatch:
2525

2626
env:
27+
# As defined by the Taskfile's PROJECT_NAME variable
28+
PROJECT_NAME: arduino-cli
2729
# As defined by the Taskfile's DIST_DIR variable
2830
DIST_DIR: dist
2931
BUILDS_ARTIFACT: build-artifacts
@@ -53,10 +55,42 @@ jobs:
5355
echo "::set-output name=result::$RESULT"
5456
5557
build:
58+
name: Build ${{ matrix.os.name }}
5659
needs: run-determination
5760
if: needs.run-determination.outputs.result == 'true'
5861
runs-on: ubuntu-latest
5962

63+
strategy:
64+
matrix:
65+
os:
66+
- dist: Windows_32bit
67+
path: "*Windows_32bit.zip"
68+
name: Windows_X86-32
69+
- dist: Windows_64bit
70+
path: "*Windows_64bit.zip"
71+
name: Windows_X86-64
72+
- dist: Linux_32bit
73+
path: "*Linux_32bit.tar.gz"
74+
name: Linux_X86-32
75+
- dist: Linux_64bit
76+
path: "*Linux_64bit.tar.gz"
77+
name: Linux_X86-64
78+
- dist: Linux_ARMv6
79+
path: "*Linux_ARMv6.tar.gz"
80+
name: Linux_ARMv6
81+
- dist: Linux_ARMv7
82+
path: "*Linux_ARMv7.tar.gz"
83+
name: Linux_ARMv7
84+
- dist: Linux_ARM64
85+
path: "*Linux_ARM64.tar.gz"
86+
name: Linux_ARM64
87+
- dist: macOS_64bit
88+
path: "*macOS_64bit.tar.gz"
89+
name: macOS_64
90+
- dist: macOS_ARM64
91+
path: "*macOS_ARM64.tar.gz"
92+
name: macOS_ARM64
93+
6094
steps:
6195
- name: Checkout repository
6296
uses: actions/checkout@v3
@@ -77,63 +111,44 @@ jobs:
77111
fi
78112
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
79113
export PACKAGE_NAME_PREFIX
80-
task dist:all
114+
task dist:${{ matrix.os.dist }}
81115
82-
# Transfer builds to artifacts job
83-
- name: Upload combined builds artifact
116+
- name: Upload build artifact
84117
uses: actions/upload-artifact@v3
85118
with:
86-
path: ${{ env.DIST_DIR }}
87-
name: ${{ env.BUILDS_ARTIFACT }}
119+
path: ${{ env.DIST_DIR }}/${{ matrix.os.path }}
120+
name: ${{ matrix.os.name }}
88121

89-
artifacts:
90-
name: ${{ matrix.artifact.name }} artifact
122+
checksums:
91123
needs: build
92124
runs-on: ubuntu-latest
93125

94-
strategy:
95-
matrix:
96-
artifact:
97-
- path: "*checksums.txt"
98-
name: checksums
99-
- path: "*Linux_32bit.tar.gz"
100-
name: Linux_X86-32
101-
- path: "*Linux_64bit.tar.gz"
102-
name: Linux_X86-64
103-
- path: "*Linux_ARM64.tar.gz"
104-
name: Linux_ARM64
105-
- path: "*Linux_ARMv6.tar.gz"
106-
name: Linux_ARMv6
107-
- path: "*Linux_ARMv7.tar.gz"
108-
name: Linux_ARMv7
109-
- path: "*macOS_64bit.tar.gz"
110-
name: macOS_64
111-
- path: "*macOS_ARM64.tar.gz"
112-
name: macOS_ARM64
113-
- path: "*Windows_32bit.zip"
114-
name: Windows_X86-32
115-
- path: "*Windows_64bit.zip"
116-
name: Windows_X86-64
117-
118126
steps:
119-
- name: Download combined builds artifact
127+
- name: Download build artifacts
120128
uses: actions/download-artifact@v3
121129
with:
122-
name: ${{ env.BUILDS_ARTIFACT }}
123130
path: ${{ env.BUILDS_ARTIFACT }}
124131

125-
- name: Upload individual build artifact
126-
uses: actions/upload-artifact@v3
127-
with:
128-
path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }}
129-
name: ${{ matrix.artifact.name }}
130-
131-
clean:
132-
needs: artifacts
133-
runs-on: ubuntu-latest
132+
- name: Output checksum
133+
working-directory: ${{ env.BUILDS_ARTIFACT}}
134+
run: |
135+
PACKAGE_NAME_PREFIX="test"
136+
if [ "${{ github.event_name }}" = "pull_request" ]; then
137+
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}"
138+
fi
139+
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
140+
TAG="${PACKAGE_NAME_PREFIX}git-snapshot"
141+
declare -a artifacts=($(ls -d */))
142+
for artifact in ${artifacts[@]}
143+
do
144+
cd $artifact
145+
checksum=$(sha256sum ${{ env.PROJECT_NAME }}_${TAG}*)
146+
cd ..
147+
echo $checksum >> ${TAG}-checksums.txt
148+
done
134149
135-
steps:
136-
- name: Remove unneeded combined builds artifact
137-
uses: geekyeggo/delete-artifact@v1
150+
- name: Upload checksum artifact
151+
uses: actions/upload-artifact@v3
138152
with:
139-
name: ${{ env.BUILDS_ARTIFACT }}
153+
path: ${{ env.BUILDS_ARTIFACT }}/*checksums.txt
154+
name: checksums

Diff for: .github/workflows/release-go-task.yml

+23-18
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,28 @@ jobs:
1919
create-release-artifacts:
2020
runs-on: ubuntu-latest
2121

22+
strategy:
23+
matrix:
24+
os:
25+
- Windows_32bit
26+
- Windows_64bit
27+
- Linux_32bit
28+
- Linux_64bit
29+
- Linux_ARMv6
30+
- Linux_ARMv7
31+
- Linux_ARM64
32+
- macOS_64bit
33+
- macOS_ARM64
34+
2235
steps:
2336
- name: Checkout repository
2437
uses: actions/checkout@v3
2538
with:
2639
fetch-depth: 0
2740

2841
- name: Create changelog
42+
# Avoid creating the same changelog for each os
43+
if: matrix.os == 'Windows_32bit'
2944
uses: arduino/create-changelog@v1
3045
with:
3146
tag-regex: '^[0-9]+\.[0-9]+\.[0-9]+.*$'
@@ -40,7 +55,7 @@ jobs:
4055
version: 3.x
4156

4257
- name: Build
43-
run: task dist:all
58+
run: task dist:${{ matrix.os }}
4459

4560
- name: Upload artifacts
4661
uses: actions/upload-artifact@v3
@@ -132,14 +147,10 @@ jobs:
132147
run: |
133148
gon "${{ env.GON_CONFIG_PATH }}"
134149
135-
- name: Re-package binary and output checksum
150+
- name: Re-package binary
136151
id: re-package
137152
working-directory: ${{ env.DIST_DIR }}
138-
# This step performs the following:
139-
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
140-
# 2. Recalculate package checksum
141-
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
142-
# (it cannot be done there because of workflow job parallelization)
153+
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
143154
run: |
144155
# GitHub's upload/download-artifact@v2 actions don't preserve file permissions,
145156
# so we need to add execution permission back until the action is made to do this.
@@ -149,11 +160,9 @@ jobs:
149160
tar -czvf "$PACKAGE_FILENAME" \
150161
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
151162
-C ../../ LICENSE.txt
152-
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
153163
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
154-
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
155164
156-
- name: Upload artifacts
165+
- name: Upload artifact
157166
uses: actions/upload-artifact@v3
158167
with:
159168
if-no-files-found: error
@@ -171,15 +180,11 @@ jobs:
171180
name: ${{ env.ARTIFACT_NAME }}
172181
path: ${{ env.DIST_DIR }}
173182

174-
- name: Update checksum
183+
- name: Output checksum
184+
working-directory: ${{ env.DIST_DIR}}
175185
run: |
176-
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
177-
for checksum_line in "${checksum_lines[@]}"
178-
do
179-
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
180-
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
181-
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
182-
done
186+
TAG="${GITHUB_REF/refs\/tags\//}"
187+
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* >> ${TAG}-checksums.txt
183188
184189
- name: Identify Prerelease
185190
# This is a workaround while waiting for create-release action

0 commit comments

Comments
 (0)