Debian Codegraph @

.github/workflows/check-general-formatting-task.yml

raw
1 # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-general-formatting-task.md
2 name: Check General Formatting
3
4 # See: https://docs.github.com/actions/reference/workflows-and-actions/events-that-trigger-workflows
5 on:
6 create:
7 push:
8 pull_request:
9 schedule:
10 # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to tools.
11 - cron: "0 8 * * TUE"
12 workflow_dispatch:
13 repository_dispatch:
14
15 jobs:
16 run-determination:
17 runs-on: ubuntu-latest
18 permissions: {}
19 outputs:
20 result: ${{ steps.determination.outputs.result }}
21 steps:
22 - name: Determine if the rest of the workflow should run
23 id: determination
24 run: |
25 RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
26 # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
27 if [[
28 "${{ github.event_name }}" != "create" ||
29 "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
30 ]]; then
31 # Run the other jobs.
32 RESULT="true"
33 else
34 # There is no need to run the other jobs.
35 RESULT="false"
36 fi
37
38 echo "result=$RESULT" >>$GITHUB_OUTPUT
39
40 check:
41 needs: run-determination
42 if: needs.run-determination.outputs.result == 'true'
43 runs-on: ubuntu-latest
44 permissions:
45 contents: read
46
47 steps:
48 - name: Set environment variables
49 run: |
50 # See: https://docs.github.com/actions/reference/workflows-and-actions/workflow-commands#setting-an-environment-variable
51 echo "EC_INSTALL_PATH=${{ runner.temp }}/editorconfig-checker" >>"$GITHUB_ENV"
52
53 - name: Checkout repository
54 uses: actions/checkout@v7
55
56 - name: Install Go
57 uses: actions/setup-go@v7
58 with:
59 go-version-file: go.mod
60
61 - name: Download latest editorconfig-checker release binary package
62 id: download
63 uses: MrOctopus/[email protected]
64 with:
65 repository: editorconfig-checker/editorconfig-checker
66 excludes: prerelease, draft
67 asset: linux-amd64.tar.gz
68 target: ${{ env.EC_INSTALL_PATH }}
69
70 - name: Install editorconfig-checker
71 run: |
72 cd "${{ env.EC_INSTALL_PATH }}"
73
74 tar \
75 --extract \
76 --file="${{ steps.download.outputs.name }}"
77
78 # Give the binary a standard name
79 mv \
80 "${{ env.EC_INSTALL_PATH }}/bin/ec-linux-amd64" \
81 "${{ env.EC_INSTALL_PATH }}/bin/ec"
82
83 # Add installation to PATH:
84 # See: https://docs.github.com/actions/reference/workflows-and-actions/workflow-commands#adding-a-system-path
85 echo "${{ env.EC_INSTALL_PATH }}/bin" >>"$GITHUB_PATH"
86
87 - name: Check formatting
88 run: |
89 go tool \
90 github.com/go-task/task/v3/cmd/task \
91 --silent \
92 general:check-formatting