Skip to content

Commit fe4e009

Browse files
Update publish-go-tester-task using parallelization
Introducing the use of a matrix, greatly improves time performances during the build making process, since each build task is performed simultaneously. Furthermore, it allows to directly upload a different artifact for each build. To complete this set of changes, a separate job to calculate the checksums and upload the relative artifact has been added to the workflow.
1 parent 70daac4 commit fe4e009

File tree

1 file changed

+73
-51
lines changed

1 file changed

+73
-51
lines changed

workflow-templates/publish-go-tester-task.yml

+73-51
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ on:
2424
repository_dispatch:
2525

2626
env:
27+
# As defined by the Taskfile's PROJECT_NAME variable
28+
PROJECT_NAME: TODO_PROJECT_NAME
2729
# As defined by the Taskfile's DIST_DIR variable
2830
DIST_DIR: dist
29-
BUILDS_ARTIFACT: build-artifacts
3031

3132
jobs:
3233
run-determination:
@@ -52,86 +53,107 @@ jobs:
5253
5354
echo "::set-output name=result::$RESULT"
5455
55-
build:
56+
package-name-prefix:
5657
needs: run-determination
5758
if: needs.run-determination.outputs.result == 'true'
5859
runs-on: ubuntu-latest
59-
60+
outputs:
61+
prefix: ${{ steps.calculation.outputs.prefix }}
6062
steps:
61-
- name: Checkout repository
62-
uses: actions/checkout@v3
63-
64-
- name: Install Task
65-
uses: arduino/setup-task@v1
66-
with:
67-
repo-token: ${{ secrets.GITHUB_TOKEN }}
68-
version: 3.x
69-
70-
- name: Build
63+
- name: package name prefix calculation
64+
id: calculation
7165
run: |
7266
PACKAGE_NAME_PREFIX="test"
7367
if [ "${{ github.event_name }}" = "pull_request" ]; then
7468
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.event.number }}"
7569
fi
7670
PACKAGE_NAME_PREFIX="$PACKAGE_NAME_PREFIX-${{ github.sha }}-"
77-
export PACKAGE_NAME_PREFIX
78-
task dist:all
7971
80-
# Transfer builds to artifacts job
81-
- name: Upload combined builds artifact
82-
uses: actions/upload-artifact@v3
83-
with:
84-
path: ${{ env.DIST_DIR }}
85-
name: ${{ env.BUILDS_ARTIFACT }}
72+
echo "::set-output name=prefix::$PACKAGE_NAME_PREFIX"
8673
87-
artifacts:
88-
name: ${{ matrix.artifact.name }} artifact
89-
needs: build
74+
build:
75+
needs: package-name-prefix
76+
name: Build ${{ matrix.os.name }}
9077
runs-on: ubuntu-latest
9178

9279
strategy:
9380
matrix:
94-
artifact:
95-
- path: "*checksums.txt"
96-
name: checksums
97-
- path: "*Linux_32bit.tar.gz"
81+
os:
82+
- task: Windows_32bit
83+
path: "*Windows_32bit.zip"
84+
name: Windows_X86-32
85+
- task: Windows_64bit
86+
path: "*Windows_64bit.zip"
87+
name: Windows_X86-64
88+
- task: Linux_32bit
89+
path: "*Linux_32bit.tar.gz"
9890
name: Linux_X86-32
99-
- path: "*Linux_64bit.tar.gz"
91+
- task: Linux_64bit
92+
path: "*Linux_64bit.tar.gz"
10093
name: Linux_X86-64
101-
- path: "*Linux_ARM64.tar.gz"
102-
name: Linux_ARM64
103-
- path: "*Linux_ARMv6.tar.gz"
94+
- task: Linux_ARMv6
95+
path: "*Linux_ARMv6.tar.gz"
10496
name: Linux_ARMv6
105-
- path: "*Linux_ARMv7.tar.gz"
97+
- task: Linux_ARMv7
98+
path: "*Linux_ARMv7.tar.gz"
10699
name: Linux_ARMv7
107-
- path: "*macOS_64bit.tar.gz"
100+
- task: Linux_ARM64
101+
path: "*Linux_ARM64.tar.gz"
102+
name: Linux_ARM64
103+
- task: macOS_64bit
104+
path: "*macOS_64bit.tar.gz"
108105
name: macOS_64
109-
- path: "*macOS_ARM64.tar.gz"
106+
- task: macOS_ARM64
107+
path: "*macOS_ARM64.tar.gz"
110108
name: macOS_ARM64
111-
- path: "*Windows_32bit.zip"
112-
name: Windows_X86-32
113-
- path: "*Windows_64bit.zip"
114-
name: Windows_X86-64
115109

116110
steps:
117-
- name: Download combined builds artifact
118-
uses: actions/download-artifact@v3
111+
- name: Checkout repository
112+
uses: actions/checkout@v3
113+
114+
- name: Install Task
115+
uses: arduino/setup-task@v1
119116
with:
120-
name: ${{ env.BUILDS_ARTIFACT }}
121-
path: ${{ env.BUILDS_ARTIFACT }}
117+
repo-token: ${{ secrets.GITHUB_TOKEN }}
118+
version: 3.x
122119

123-
- name: Upload individual build artifact
120+
- name: Build
121+
run: |
122+
PACKAGE_NAME_PREFIX=${{ needs.package-name-prefix.outputs.prefix }}
123+
export PACKAGE_NAME_PREFIX
124+
task dist:${{ matrix.os.task }}
125+
126+
# Transfer builds to artifacts job
127+
- name: Upload build artifact
124128
uses: actions/upload-artifact@v3
125129
with:
126-
path: ${{ env.BUILDS_ARTIFACT }}/${{ matrix.artifact.path }}
127-
name: ${{ matrix.artifact.name }}
130+
path: ${{ env.DIST_DIR }}/${{ matrix.os.path }}
131+
name: ${{ matrix.os.name }}
128132

129-
clean:
130-
needs: artifacts
133+
checksums:
134+
needs:
135+
- build
136+
- package-name-prefix
131137
runs-on: ubuntu-latest
132138

133139
steps:
134-
- name: Remove unneeded combined builds artifact
135-
uses: geekyeggo/delete-artifact@v1
140+
- name: Download build artifacts
141+
uses: actions/download-artifact@v3
142+
143+
- name: Create checksum file
144+
run: |
145+
TAG="${{ needs.package-name-prefix.outputs.prefix }}git-snapshot"
146+
declare -a artifacts=($(ls -d */))
147+
for artifact in ${artifacts[@]}
148+
do
149+
cd $artifact
150+
checksum=$(sha256sum ${{ env.PROJECT_NAME }}_${TAG}*)
151+
cd ..
152+
echo $checksum >> ${TAG}-checksums.txt
153+
done
154+
155+
- name: Upload checksum artifact
156+
uses: actions/upload-artifact@v3
136157
with:
137-
name: ${{ env.BUILDS_ARTIFACT }}
158+
path: ./*checksums.txt
159+
name: checksums

0 commit comments

Comments
 (0)