|
| 1 | +# Source: https://github.com/arduino/tooling-project-assets/blob/master/workflow-templates/check-general-formatting-task.md |
| 2 | +name: Check General Formatting |
| 3 | + |
| 4 | +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows |
| 5 | +on: |
| 6 | + push: |
| 7 | + pull_request: |
| 8 | + schedule: |
| 9 | + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to tools. |
| 10 | + - cron: "0 8 * * TUE" |
| 11 | + workflow_dispatch: |
| 12 | + repository_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + check: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Set environment variables |
| 20 | + run: | |
| 21 | + # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable |
| 22 | + echo "EC_INSTALL_PATH=${{ runner.temp }}/editorconfig-checker" >> "$GITHUB_ENV" |
| 23 | +
|
| 24 | + - name: Checkout repository |
| 25 | + uses: actions/checkout@v2 |
| 26 | + |
| 27 | + - name: Install Task |
| 28 | + uses: arduino/setup-task@v1 |
| 29 | + with: |
| 30 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + version: 3.x |
| 32 | + |
| 33 | + - name: Get data for latest editorconfig-checker release |
| 34 | + id: get-release-data |
| 35 | + |
| 36 | + env: |
| 37 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + with: |
| 39 | + # Pre-releases are ignored |
| 40 | + route: GET /repos/:owner/:repo/releases/latest |
| 41 | + # The following inputs result in "Unexpected input" warnings on the workflow run log and summary page, |
| 42 | + # but they are correct |
| 43 | + owner: editorconfig-checker |
| 44 | + repo: editorconfig-checker |
| 45 | + |
| 46 | + - name: Download release binary |
| 47 | + id: download-release |
| 48 | + uses: carlosperate/[email protected] |
| 49 | + with: |
| 50 | + # See: https://github.com/editorconfig-checker/editorconfig-checker/releases |
| 51 | + file-url: https://github.com/editorconfig-checker/editorconfig-checker/releases/download/${{ fromJson(steps.get-release-data.outputs.data).tag_name }}/ec-linux-amd64.tar.gz |
| 52 | + location: ${{ env.EC_INSTALL_PATH }} |
| 53 | + |
| 54 | + - name: Install editorconfig-checker |
| 55 | + run: | |
| 56 | + cd "${{ env.EC_INSTALL_PATH }}" |
| 57 | + tar --extract --file="${{ steps.download-release.outputs.file-path }}" |
| 58 | + # Give the binary a standard name |
| 59 | + mv "${{ env.EC_INSTALL_PATH }}/bin/ec-linux-amd64" "${{ env.EC_INSTALL_PATH }}/bin/ec" |
| 60 | + # Add installation to PATH: |
| 61 | + # See: https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#adding-a-system-path |
| 62 | + echo "${{ env.EC_INSTALL_PATH }}/bin" >> "$GITHUB_PATH" |
| 63 | +
|
| 64 | + - name: Check formatting |
| 65 | + run: task --silent general:check-formatting |
0 commit comments