Skip to content

Commit cd44376

Browse files
authored
Merge pull request #77 from per1234/sync-ci
Sync project assets with "templates"
2 parents 62cafe4 + 4e2ed7f commit cd44376

File tree

29 files changed

+254
-59
lines changed

29 files changed

+254
-59
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[codespell]
44
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
55
ignore-words-list = easly,pullrequest
6+
skip = ./.git,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock
67
builtin = clear,informal,en-GB_to_en-US
78
check-filenames =
89
check-hidden =
9-
skip = ./.git,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock

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

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-task.md
12
name: Check Go
23

34
env:
@@ -6,17 +7,18 @@ env:
67

78
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
89
on:
10+
create:
911
push:
1012
paths:
11-
- ".github/workflows/check-go-task.yml"
12-
- "Taskfile.yml"
13+
- ".github/workflows/check-go-task.ya?ml"
14+
- "Taskfile.ya?ml"
1315
- "**/go.mod"
1416
- "**/go.sum"
1517
- "**.go"
1618
pull_request:
1719
paths:
18-
- ".github/workflows/check-go-task.yml"
19-
- "Taskfile.yml"
20+
- ".github/workflows/check-go-task.ya?ml"
21+
- "Taskfile.ya?ml"
2022
- "**/go.mod"
2123
- "**/go.sum"
2224
- "**.go"
@@ -27,8 +29,33 @@ on:
2729
repository_dispatch:
2830

2931
jobs:
32+
run-determination:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
result: ${{ steps.determination.outputs.result }}
36+
steps:
37+
- name: Determine if the rest of the workflow should run
38+
id: determination
39+
run: |
40+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
41+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
42+
if [[ \
43+
"${{ github.event_name }}" != "create" || \
44+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
45+
]]; then
46+
# Run the other jobs.
47+
RESULT="true"
48+
else
49+
# There is no need to run the other jobs.
50+
RESULT="false"
51+
fi
52+
53+
echo "::set-output name=result::$RESULT"
54+
3055
check-errors:
3156
name: check-errors (${{ matrix.module.path }})
57+
needs: run-determination
58+
if: needs.run-determination.outputs.result == 'true'
3259
runs-on: ubuntu-latest
3360

3461
strategy:
@@ -60,6 +87,8 @@ jobs:
6087

6188
check-outdated:
6289
name: check-outdated (${{ matrix.module.path }})
90+
needs: run-determination
91+
if: needs.run-determination.outputs.result == 'true'
6392
runs-on: ubuntu-latest
6493

6594
strategy:
@@ -94,6 +123,8 @@ jobs:
94123

95124
check-style:
96125
name: check-style (${{ matrix.module.path }})
126+
needs: run-determination
127+
if: needs.run-determination.outputs.result == 'true'
97128
runs-on: ubuntu-latest
98129

99130
strategy:
@@ -128,6 +159,8 @@ jobs:
128159

129160
check-formatting:
130161
name: check-formatting (${{ matrix.module.path }})
162+
needs: run-determination
163+
if: needs.run-determination.outputs.result == 'true'
131164
runs-on: ubuntu-latest
132165

133166
strategy:
@@ -162,6 +195,8 @@ jobs:
162195

163196
check-config:
164197
name: check-config (${{ matrix.module.path }})
198+
needs: run-determination
199+
if: needs.run-determination.outputs.result == 'true'
165200
runs-on: ubuntu-latest
166201

167202
strategy:
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/release.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
release:
1414
runs-on: ubuntu-latest
1515

16+
env:
17+
# See: https://github.com/fsaintjacques/semver-tool/releases
18+
SEMVER_TOOL_VERSION: 3.2.0
19+
1620
steps:
1721
- name: Set environment variables
1822
run: |
@@ -21,6 +25,7 @@ jobs:
2125
echo "TAG_SHORT_NAME=$TAG_SHORT_NAME" >> "$GITHUB_ENV"
2226
echo "ARCHIVE_PATH=${{ runner.temp }}/libraries-repository-engine_${TAG_SHORT_NAME}_Linux_64bit.tar.gz" >> "$GITHUB_ENV"
2327
echo "CHANGELOG_PATH=${{ runner.temp }}/CHANGELOG.md" >> "$GITHUB_ENV"
28+
echo "SEMVER_TOOL_PATH=${{ runner.temp }}/semver" >> "$GITHUB_ENV"
2429
2530
- name: Checkout repository
2631
uses: actions/checkout@v2
@@ -58,20 +63,26 @@ jobs:
5863
case-insensitive-regex: true
5964
changelog-file-path: ${{ env.CHANGELOG_PATH }}
6065

61-
- name: Identify pre-releases
66+
- name: Download semver tool
67+
id: download-semver-tool
68+
uses: carlosperate/download-file-action@v1.0.3
69+
with:
70+
file-url: https://github.com/fsaintjacques/semver-tool/archive/${{ env.SEMVER_TOOL_VERSION }}.zip
71+
location: ${{ runner.temp }}/semver-tool
72+
73+
- name: Install semver tool
74+
run: |
75+
unzip \
76+
-p \
77+
"${{ steps.download-semver-tool.outputs.file-path }}" \
78+
semver-tool-${{ env.SEMVER_TOOL_VERSION }}/src/semver > \
79+
"${{ env.SEMVER_TOOL_PATH }}"
80+
chmod +x "${{ env.SEMVER_TOOL_PATH }}"
81+
82+
- name: Identify Prerelease
6283
id: prerelease
63-
env:
64-
# See: https://github.com/fsaintjacques/semver-tool/releases/latest
65-
TOOL_VERSION: 3.2.0
6684
run: |
67-
INSTALL_PATH="${{ runner.temp }}/semver-tool"
68-
mkdir -p "$INSTALL_PATH"
69-
wget --quiet --directory-prefix="$INSTALL_PATH" https://github.com/fsaintjacques/semver-tool/archive/${{ env.TOOL_VERSION }}.zip
70-
unzip -p "${INSTALL_PATH}/${{ env.TOOL_VERSION }}.zip" semver-tool-${{ env.TOOL_VERSION }}/src/semver >"${INSTALL_PATH}/semver"
71-
chmod +x "${INSTALL_PATH}/semver"
72-
if [[ $("${INSTALL_PATH}/semver" get prerel "${{ env.TAG_SHORT_NAME }}") ]]; then
73-
echo "::set-output name=is-pre::true";
74-
fi
85+
if [[ "$("${{ env.SEMVER_TOOL_PATH }}" get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
7586
7687
- name: Create Release
7788
uses: ncipollo/release-action@v1

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

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ env:
99

1010
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
1111
on:
12+
create:
1213
push:
1314
paths:
1415
- ".github/workflows/test-go-integration-task.ya?ml"
@@ -18,7 +19,7 @@ on:
1819
- "go.sum"
1920
- "poetry.lock"
2021
- "pyproject.toml"
21-
- "test/**"
22+
- "tests/**"
2223
pull_request:
2324
paths:
2425
- ".github/workflows/test-go-integration-task.ya?ml"
@@ -28,7 +29,7 @@ on:
2829
- "go.sum"
2930
- "poetry.lock"
3031
- "pyproject.toml"
31-
- "test/**"
32+
- "tests/**"
3233
schedule:
3334
# Run daily at 8 AM UTC to catch breakage resulting from changes to Arduino Lint.
3435
- cron: "0 8 * * *"
@@ -40,8 +41,39 @@ on:
4041
repository_dispatch:
4142

4243
jobs:
43-
test:
44+
run-determination:
4445
runs-on: ubuntu-latest
46+
outputs:
47+
result: ${{ steps.determination.outputs.result }}
48+
steps:
49+
- name: Determine if the rest of the workflow should run
50+
id: determination
51+
run: |
52+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
53+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
54+
if [[ \
55+
"${{ github.event_name }}" != "create" || \
56+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX \
57+
]]; then
58+
# Run the other jobs.
59+
RESULT="true"
60+
else
61+
# There is no need to run the other jobs.
62+
RESULT="false"
63+
fi
64+
65+
echo "::set-output name=result::$RESULT"
66+
67+
test:
68+
needs: run-determination
69+
if: needs.run-determination.outputs.result == 'true'
70+
71+
strategy:
72+
matrix:
73+
operating-system:
74+
- ubuntu-latest
75+
76+
runs-on: ${{ matrix.operating-system }}
4577

4678
env:
4779
ARDUINO_LINT_SOURCE_PATH: arduino-lint

0 commit comments

Comments
 (0)