Skip to content

Commit ef5d8e6

Browse files
committed
Move tester build to dedicated workflow
This procedure was not directly related to the test running procedure, so there was no good reason for it to be located in the "Test Go" CI workflow.
1 parent 279ed32 commit ef5d8e6

File tree

2 files changed

+95
-30
lines changed

2 files changed

+95
-30
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/publish-go-tester-task.md
2+
name: Publish Tester Build
3+
4+
env:
5+
# See: https://github.com/actions/setup-go/tree/v2#readme
6+
GO_VERSION: "1.16"
7+
8+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
9+
on:
10+
create:
11+
push:
12+
paths:
13+
- ".github/workflows/publish-go-tester-task.ya?ml"
14+
- "go.mod"
15+
- "go.sum"
16+
- "Taskfile.ya?ml"
17+
- "**.go"
18+
pull_request:
19+
paths:
20+
- ".github/workflows/publish-go-tester-task.ya?ml"
21+
- "go.mod"
22+
- "go.sum"
23+
- "Taskfile.ya?ml"
24+
- "**.go"
25+
workflow_dispatch:
26+
repository_dispatch:
27+
28+
jobs:
29+
run-determination:
30+
runs-on: ubuntu-latest
31+
outputs:
32+
result: ${{ steps.determination.outputs.result }}
33+
steps:
34+
- name: Determine if the rest of the workflow should run
35+
id: determination
36+
run: |
37+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
38+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
39+
if [[ \
40+
"${{ github.event_name }}" != "create" || \
41+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
42+
]]; then
43+
# Run the other jobs.
44+
RESULT="true"
45+
else
46+
# There is no need to run the other jobs.
47+
RESULT="false"
48+
fi
49+
50+
echo "::set-output name=result::$RESULT"
51+
52+
build:
53+
needs: run-determination
54+
if: needs.run-determination.outputs.result == 'true'
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- name: Set environment variables
59+
run: |
60+
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
61+
echo "BUILD_ARCHIVE_PATH=${{ runner.temp }}/libraries-repository-engine_${{ github.sha }}_Linux_64bit.zip" >> "$GITHUB_ENV"
62+
63+
- name: Checkout repository
64+
uses: actions/checkout@v2
65+
66+
- name: Install Go
67+
uses: actions/setup-go@v2
68+
with:
69+
go-version: ${{ env.GO_VERSION }}
70+
71+
- name: Install Task
72+
uses: arduino/setup-task@v1
73+
with:
74+
repo-token: ${{ secrets.GITHUB_TOKEN }}
75+
version: 3.x
76+
77+
- name: Build application
78+
run: task go:build
79+
80+
# actions/upload-artifact does not maintain file permissions. Putting the executable in an archive avoids the
81+
# application becoming non-executable.
82+
- name: Archive build
83+
run: |
84+
zip \
85+
-j \
86+
"${{ env.BUILD_ARCHIVE_PATH }}" \
87+
"./libraries-repository-engine" \
88+
"./LICENSE.txt"
89+
90+
- name: Save binary as workflow artifact
91+
uses: actions/upload-artifact@v2
92+
with:
93+
if-no-files-found: error
94+
path: ${{ env.BUILD_ARCHIVE_PATH }}
95+
name: libraries-repository-engine

.github/workflows/test-go-task.yml

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -53,36 +53,6 @@ jobs:
5353
5454
echo "::set-output name=result::$RESULT"
5555
56-
build:
57-
needs: run-determination
58-
if: needs.run-determination.outputs.result == 'true'
59-
runs-on: ubuntu-latest
60-
61-
steps:
62-
- name: Checkout repository
63-
uses: actions/checkout@v2
64-
65-
- name: Install Go
66-
uses: actions/setup-go@v2
67-
with:
68-
go-version: ${{ env.GO_VERSION }}
69-
70-
- name: Install Task
71-
uses: arduino/setup-task@v1
72-
with:
73-
repo-token: ${{ secrets.GITHUB_TOKEN }}
74-
version: 3.x
75-
76-
- name: Build application
77-
run: task go:build
78-
79-
- name: Save binary as workflow artifact
80-
uses: actions/upload-artifact@v2
81-
with:
82-
if-no-files-found: error
83-
path: libraries-repository-engine
84-
name: libraries-repository-engine
85-
8656
test:
8757
name: test (${{ matrix.module.path }} - ${{ matrix.operating-system }})
8858
needs: run-determination

0 commit comments

Comments
 (0)