Skip to content

Sync workflows with their upstream template #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/check-go-dependencies-task.yml
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ jobs:
RESULT="false"
fi
echo "::set-output name=result::$RESULT"
echo "result=$RESULT" >> $GITHUB_OUTPUT
check-cache:
needs: run-determination
@@ -69,6 +69,12 @@ jobs:
with:
submodules: recursive

# This is required to allow jonabc/setup-licensed to install licensed via Ruby gem.
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby # Install latest version

- name: Install licensed
uses: jonabc/setup-licensed@v1
with:
@@ -119,6 +125,12 @@ jobs:
with:
submodules: recursive

# This is required to allow jonabc/setup-licensed to install licensed via Ruby gem.
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ruby # Install latest version

- name: Install licensed
uses: jonabc/setup-licensed@v1
with:
2 changes: 1 addition & 1 deletion .github/workflows/check-go-task.yml
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ jobs:
RESULT="false"
fi
echo "::set-output name=result::$RESULT"
echo "result=$RESULT" >> $GITHUB_OUTPUT
check-errors:
name: check-errors (${{ matrix.module.path }})
2 changes: 1 addition & 1 deletion .github/workflows/check-license.yml
Original file line number Diff line number Diff line change
@@ -54,7 +54,7 @@ jobs:
RESULT="false"
fi
echo "::set-output name=result::$RESULT"
echo "result=$RESULT" >> $GITHUB_OUTPUT
check-license:
needs: run-determination
2 changes: 1 addition & 1 deletion .github/workflows/check-markdown-task.yml
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ jobs:
RESULT="false"
fi
echo "::set-output name=result::$RESULT"
echo "result=$RESULT" >> $GITHUB_OUTPUT
lint:
needs: run-determination
30 changes: 28 additions & 2 deletions .github/workflows/check-taskfiles.yml
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ env:

# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
create:
push:
paths:
- ".github/workflows/check-taskfiles.ya?ml"
@@ -28,8 +29,33 @@ on:
repository_dispatch:

jobs:
run-determination:
runs-on: ubuntu-latest
outputs:
result: ${{ steps.determination.outputs.result }}
steps:
- name: Determine if the rest of the workflow should run
id: determination
run: |
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
if [[
"${{ github.event_name }}" != "create" ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
]]; then
# Run the other jobs.
RESULT="true"
else
# There is no need to run the other jobs.
RESULT="false"
fi
echo "result=$RESULT" >> $GITHUB_OUTPUT
validate:
name: Validate ${{ matrix.file }}
needs: run-determination
if: needs.run-determination.outputs.result == 'true'
runs-on: ubuntu-latest

strategy:
@@ -53,8 +79,8 @@ jobs:
id: download-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
file-url: https://json.schemastore.org/taskfile.json
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
file-url: https://taskfile.dev/schema.json
location: ${{ runner.temp }}/taskfile-schema

- name: Install JSON schema validator
62 changes: 38 additions & 24 deletions .github/workflows/release-go-task.yml
Original file line number Diff line number Diff line change
@@ -19,13 +19,28 @@ jobs:
create-release-artifacts:
runs-on: ubuntu-latest

strategy:
matrix:
os:
- Windows_32bit
- Windows_64bit
- Linux_32bit
- Linux_64bit
- Linux_ARMv6
- Linux_ARMv7
- Linux_ARM64
- macOS_64bit
- macOS_ARM64

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

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

- name: Build
run: task dist:all
run: task dist:${{ matrix.os }}

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_DIR }}

notarize-macos:
name: Notarize ${{ matrix.artifact.name }}
runs-on: macos-latest
@@ -82,7 +97,8 @@ jobs:
env:
KEYCHAIN: "sign.keychain"
INSTALLER_CERT_MAC_PATH: "/tmp/ArduinoCerts2020.p12"
KEYCHAIN_PASSWORD: keychainpassword # Arbitrary password for a keychain that exists only for the duration of the job, so not secret
# Arbitrary password for a keychain that exists only for the duration of the job, so not secret
KEYCHAIN_PASSWORD: keychainpassword
run: |
echo "${{ secrets.INSTALLER_CERT_MAC_P12 }}" | base64 --decode > "${{ env.INSTALLER_CERT_MAC_PATH }}"
security create-keychain -p "${{ env.KEYCHAIN_PASSWORD }}" "${{ env.KEYCHAIN }}"
@@ -132,14 +148,10 @@ jobs:
run: |
gon "${{ env.GON_CONFIG_PATH }}"
- name: Re-package binary and output checksum
- name: Re-package binary
id: re-package
working-directory: ${{ env.DIST_DIR }}
# This step performs the following:
# 1. Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
# 2. Recalculate package checksum
# 3. Output the new checksum to include in the nnnnnn-checksums.txt file
# (it cannot be done there because of workflow job parallelization)
# Repackage the signed binary replaced in place by Gon (ignoring the output zip file)
run: |
# GitHub's upload/download-artifact actions don't preserve file permissions,
# so we need to add execution permission back until the action is made to do this.
@@ -149,11 +161,9 @@ jobs:
tar -czvf "$PACKAGE_FILENAME" \
-C "${{ env.PROJECT_NAME }}_osx_${{ matrix.artifact.name }}/" "${{ env.PROJECT_NAME }}" \
-C ../../ LICENSE.txt
CHECKSUM_LINE="$(shasum -a 256 $PACKAGE_FILENAME)"
echo "PACKAGE_FILENAME=$PACKAGE_FILENAME" >> $GITHUB_ENV
echo "::set-output name=checksum-${{ matrix.artifact.name }}::$CHECKSUM_LINE"
- name: Upload artifacts
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
@@ -170,25 +180,29 @@ jobs:
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.DIST_DIR }}

- name: Update checksum

- name: Create checksum file
working-directory: ${{ env.DIST_DIR}}
run: |
declare -a checksum_lines=("${{ needs.notarize-macos.outputs.checksum-darwin_amd64 }}" "${{ needs.notarize-macos.outputs.checksum-darwin_arm64 }}")
for checksum_line in "${checksum_lines[@]}"
do
CHECKSUM=$(echo ${checksum_line} | cut -d " " -f 1)
PACKAGE_FILENAME=$(echo ${checksum_line} | cut -d " " -f 2)
perl -pi -w -e "s/.*${PACKAGE_FILENAME}/${CHECKSUM} ${PACKAGE_FILENAME}/g;" ${{ env.DIST_DIR }}/*-checksums.txt
done
TAG="${GITHUB_REF/refs\/tags\//}"
sha256sum ${{ env.PROJECT_NAME }}_${TAG}* > ${TAG}-checksums.txt
- name: Identify Prerelease
# This is a workaround while waiting for create-release action
# to implement auto pre-release based on tag
id: prerelease
run: |
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.0.0.zip
unzip -p /tmp/3.0.0.zip semver-tool-3.0.0/src/semver >/tmp/semver && chmod +x /tmp/semver
if [[ "$(/tmp/semver get prerel "${GITHUB_REF/refs\/tags\//}")" ]]; then echo "::set-output name=IS_PRE::true"; fi
wget -q -P /tmp https://github.com/fsaintjacques/semver-tool/archive/3.2.0.zip
unzip -p /tmp/3.2.0.zip semver-tool-3.2.0/src/semver >/tmp/semver && chmod +x /tmp/semver
if [[ \
"$(
/tmp/semver get prerel \
"${GITHUB_REF/refs\/tags\//}"
)" != \
"" \
]]; then
echo "IS_PRE=true" >> $GITHUB_OUTPUT
fi
- name: Create Github Release and upload artifacts
uses: ncipollo/release-action@v1
6 changes: 3 additions & 3 deletions .github/workflows/sync-labels.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels.md
name: Sync Labels

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
push:
paths:
@@ -86,7 +86,7 @@ jobs:
steps:
- name: Set environment variables
run: |
# See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
# See: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
echo "MERGED_CONFIGURATION_PATH=${{ runner.temp }}/labels.yml" >> "$GITHUB_ENV"
- name: Determine whether to dry run
@@ -103,7 +103,7 @@ jobs:
run: |
# Use of this flag in the github-label-sync command will cause it to only check the validity of the
# configuration.
echo "::set-output name=flag::--dry-run"
echo "flag=--dry-run" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v3
25 changes: 1 addition & 24 deletions DistTasks.yml
Original file line number Diff line number Diff line change
@@ -20,22 +20,8 @@ version: "3"
vars:
CONTAINER: "docker.elastic.co/beats-dev/golang-crossbuild"
GO_VERSION: "1.18.3"
CHECKSUM_FILE: "{{.VERSION}}-checksums.txt"

tasks:
all:
desc: Build for distribution for all platforms
cmds:
- task: Windows_32bit
- task: Windows_64bit
- task: Linux_32bit
- task: Linux_64bit
- task: Linux_ARMv6
- task: Linux_ARMv7
- task: Linux_ARM64
- task: macOS_64bit
- task: macOS_ARM64

Windows_32bit:
desc: Builds Windows 32 bit binaries
dir: "{{.DIST_DIR}}"
@@ -48,7 +34,6 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_windows_386"
@@ -70,7 +55,6 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
zip {{.PACKAGE_NAME}} {{.PLATFORM_DIR}}/{{.PROJECT_NAME}}.exe ../LICENSE.txt -j
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_windows_amd64"
@@ -92,7 +76,6 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd32"
@@ -114,7 +97,6 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd64"
@@ -136,7 +118,6 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
@@ -158,7 +139,6 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
@@ -208,10 +188,9 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64"
BUILD_COMMAND: "go build -o {{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}} {{.LDFLAGS}}"
BUILD_PLATFORM: "linux/arm64"
CONTAINER_TAG: "{{.GO_VERSION}}-arm"
@@ -230,7 +209,6 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_amd64"
@@ -265,7 +243,6 @@ tasks:
-p "{{.BUILD_PLATFORM}}"
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
sha256sum {{.PACKAGE_NAME}} >> {{.CHECKSUM_FILE}}
vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_osx_darwin_arm64"
29 changes: 21 additions & 8 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,11 @@ vars:
DEFAULT_GO_MODULE_PATH: ./
DEFAULT_GO_PACKAGES:
sh: |
echo $(cd {{default "./" .GO_MODULE_PATH}} && go list ./... | tr '\n' ' ' || echo '"ERROR: Unable to discover Go packages"')
echo $(
cd {{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}} &&
go list ./... | tr '\n' ' ' ||
echo '"ERROR: Unable to discover Go packages"'
)
# build vars
COMMIT:
sh: echo "$(git log --no-show-signature -n 1 --format=%h)"
@@ -45,17 +49,25 @@ tasks:
docs:generate:
desc: Create all generated documentation content

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-dependencies-task/Taskfile.yml
general:prepare-deps:
desc: Prepare project dependencies for license check
# No preparation is needed for Go module-based projects.

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies-task/Taskfile.yml
general:cache-dep-licenses:
desc: Cache dependency license metadata
deps:
- task: general:prepare-deps
cmds:
- |
if ! which licensed &>/dev/null; then
if [[ {{OS}} == "windows" ]]; then
echo "Licensed does not have Windows support."
echo "Please use Linux/macOS or download the dependencies cache from the GitHub Actions workflow artifact."
else
echo "licensed not found or not in PATH. Please install: https://github.com/github/licensed#as-an-executable"
echo "licensed not found or not in PATH."
echo "Please install: https://github.com/github/licensed#as-an-executable"
fi
exit 1
fi
@@ -78,7 +90,7 @@ tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/go-task/Taskfile.yml
go:build:
desc: Build the Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
dir: "{{.DEFAULT_GO_MODULE_PATH}}"
cmds:
- go build -v {{.LDFLAGS}}

@@ -95,21 +107,21 @@ tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:fix:
desc: Modernize usages of outdated APIs
dir: '{{default "./" .GO_MODULE_PATH}}'
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go fix {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:format:
desc: Format Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go fmt {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:lint:
desc: Lint Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- |
if ! which golint &>/dev/null; then
@@ -148,7 +160,7 @@ tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-go-task/Taskfile.yml
go:vet:
desc: Check for errors in Go code
dir: '{{default "./" .GO_MODULE_PATH}}'
dir: "{{default .DEFAULT_GO_MODULE_PATH .GO_MODULE_PATH}}"
cmds:
- go vet {{default .DEFAULT_GO_PACKAGES .GO_PACKAGES}}

@@ -164,7 +176,8 @@ tasks:
# npx --call uses the native shell, which makes it too difficult to use npx for this application on Windows,
# so the Windows user is required to have markdown-link-check installed and in PATH.
if ! which markdown-link-check &>/dev/null; then
echo "markdown-link-check not found or not in PATH. Please install: https://github.com/tcort/markdown-link-check#readme"
echo "markdown-link-check not found or not in PATH."
echo "Please install: https://github.com/tcort/markdown-link-check#readme"
exit 1
fi
# Default behavior of the task on Windows is to exit the task when the first broken link causes a non-zero
450 changes: 169 additions & 281 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"devDependencies": {
"ajv-cli": "^5.0.0",
"ajv-formats": "^2.1.1",
"markdown-link-check": "^3.10.2",
"markdownlint-cli": "^0.32.1"
"markdown-link-check": "^3.11.2",
"markdownlint-cli": "^0.33.0"
}
}