|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: [main, devel] |
| 4 | + pull_request: |
| 5 | + |
| 6 | +name: pre-commit.yaml |
| 7 | + |
| 8 | +permissions: read-all |
| 9 | + |
| 10 | +jobs: |
| 11 | + pre-commit: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + env: |
| 14 | + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - uses: actions/setup-python@v5 |
| 19 | + with: |
| 20 | + python-version: "3.12" |
| 21 | + |
| 22 | + - uses: r-lib/actions/setup-r@v2 |
| 23 | + with: |
| 24 | + use-public-rspm: true |
| 25 | + |
| 26 | + - name: Install Rcpp |
| 27 | + run: Rscript -e 'install.packages("Rcpp")' |
| 28 | + |
| 29 | + - name: Install system dependencies |
| 30 | + run: | |
| 31 | + sudo apt-get update |
| 32 | + sudo apt-get install --yes clang-format clang-tidy |
| 33 | +
|
| 34 | + - name: Install Air |
| 35 | + uses: posit-dev/setup-air@v1 |
| 36 | + |
| 37 | + - name: Install Jarl |
| 38 | + run: | |
| 39 | + curl --proto '=https' --tlsv1.2 -LsSf \ |
| 40 | + https://github.com/etiennebacher/jarl/releases/latest/download/jarl-installer.sh | sh |
| 41 | + echo "$HOME/.local/bin" >> "$GITHUB_PATH" |
| 42 | +
|
| 43 | + - name: Install pre-commit |
| 44 | + run: python -m pip install --upgrade pre-commit |
| 45 | + |
| 46 | + - name: Run pre-commit (pull request) |
| 47 | + if: github.event_name == 'pull_request' |
| 48 | + run: | |
| 49 | + pre-commit run \ |
| 50 | + --from-ref "${{ github.event.pull_request.base.sha }}" \ |
| 51 | + --to-ref "${{ github.event.pull_request.head.sha }}" \ |
| 52 | + --show-diff-on-failure |
| 53 | +
|
| 54 | + - name: Run pre-commit (push) |
| 55 | + if: github.event_name == 'push' && github.event.before != '0000000000000000000000000000000000000000' |
| 56 | + run: | |
| 57 | + pre-commit run \ |
| 58 | + --from-ref "${{ github.event.before }}" \ |
| 59 | + --to-ref "${{ github.sha }}" \ |
| 60 | + --show-diff-on-failure |
| 61 | +
|
| 62 | + - name: Run pre-commit (bootstrap) |
| 63 | + if: github.event_name == 'push' && github.event.before == '0000000000000000000000000000000000000000' |
| 64 | + run: pre-commit run --all-files --show-diff-on-failure |
0 commit comments