ci: Use pull request head reference for testing (#331) #468
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: test | |
on: | |
push: | |
branches: | |
- master | |
pull_request_target: | |
branches: | |
- master | |
types: | |
- opened | |
- synchronize | |
- reopened | |
jobs: | |
test-against-emacs-stable-releases: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
emacs_version: | |
- 27.2 | |
- 28.2 | |
- 29.4 | |
- release-snapshot | |
env: | |
EMACS_VERSION: ${{ matrix.emacs_version }} | |
steps: | |
- name: Setup Emacs | |
uses: purcell/setup-emacs@master | |
with: | |
version: ${{ matrix.emacs_version }} | |
- name: Setup Python (for Cask) | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
architecture: 'x64' | |
- name: Setup Cask | |
uses: conao3/setup-cask@master | |
with: | |
version: "snapshot" | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Install | |
id: install | |
run: | | |
emacs --version | |
cask build --verbose | |
make build | |
- name: Test | |
if: steps.install.outcome == 'success' && steps.install.conclusion == 'success' | |
run: | | |
make test | |
- name: Upload coverage | |
if: steps.install.outcome == 'success' && steps.install.conclusion == 'success' | |
uses: codecov/codecov-action@v5 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
env_vars: EMACS_VERSION | |
files: ./coverage/lcov-ert.info,./coverage/lcov-buttercup.info | |
fail_ci_if_error: true | |
test-against-emacs-snapshot-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Emacs | |
uses: purcell/setup-emacs@master | |
with: | |
version: "snapshot" | |
- name: Setup Python (for Cask) | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
architecture: 'x64' | |
- name: Setup Cask | |
uses: conao3/setup-cask@master | |
with: | |
version: "snapshot" | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Install | |
id: install | |
run: | | |
emacs --version | |
cask build --verbose | |
make build | |
- name: Test | |
continue-on-error: true | |
id: test | |
if: steps.install.outcome == 'success' && steps.install.conclusion == 'success' | |
run: | | |
make test | |
- name: Add comment if optional job failed; delete otherwise | |
if: github.event_name == 'pull_request' || github.event_name == 'pull_request_target' | |
uses: thollander/actions-comment-pull-request@v3 | |
with: | |
message: | | |
### ⚠️ Optional test-against-emacs-snapshot job failed ⚠️ | |
mode: ${{ steps.test.outcome == 'failure' && 'upsert' || 'delete' }} |