MRI-adaptivity #1013
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: Checks - swig | |
on: | |
pull_request: | |
workflow_dispatch: | |
issue_comment: | |
types: [created] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }} | |
cancel-in-progress: true | |
jobs: | |
swig_check: | |
if: ${{ github.event_name != 'issue_comment' || (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/autofix')) }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install swig | |
run: | | |
git clone https://github.com/sundials-codes/swig | |
cd swig | |
./autogen.sh | |
./configure --prefix=/usr/ | |
make | |
sudo make install | |
swig -version | |
- name: Check out repository code | |
if: github.event_name != 'issue_comment' | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Check out repository code | |
if: github.event_name == 'issue_comment' | |
uses: actions/checkout@v4 | |
with: | |
ref: refs/pull/${{ github.event.issue.number }}/head | |
fetch-depth: 0 | |
- name: Add safe directory | |
run: git config --global --add safe.directory "$GITHUB_WORKSPACE" | |
- name: Run swig on code | |
run: | | |
cd swig | |
make all32 | |
make all64 | |
- name: Run git diff to see if anything changed | |
run: /usr/bin/git diff --name-only --exit-code | |
- name: Run git diff if we failed | |
if: failure() | |
run: /usr/bin/git diff > swig.patch | |
- name: Archive diff as a patch if we failed | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: swig.patch | |
path: | | |
${{ github.workspace }}/swig.patch | |
apply_swig: | |
if: ${{ always() && contains(join(needs.*.result, ','), 'failure') && (github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/autofix')) }} | |
needs: swig_check | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the GitHub created reference for the PR. | |
# The only way to do this is by using the "issue" number | |
# but that is really the PR number in this context. | |
# This is due to using an `issue_comment` event which | |
# is due to the GitHub Actions API that does not have | |
# a `pull_request_comment` event or something similar. | |
# This leaves us in a detached head state which is corrected | |
# in `apply-style/checkout.sh` | |
- name: Checkout repository code | |
uses: actions/checkout@v4 | |
with: | |
ref: refs/pull/${{ github.event.issue.number }}/head | |
fetch-depth: 0 | |
- name: Checkout the right git ref | |
run: ./.github/actions/apply-style/checkout.sh | |
- name: Download the git diff from swig_check | |
uses: actions/download-artifact@v4 | |
with: | |
name: swig.patch | |
- name: Apply patch | |
run: | | |
git apply swig.patch | |
rm swig.patch | |
- name: Commit fixes | |
run: | | |
git config user.name "format-robot" | |
git config user.email "[email protected]" | |
if [ -n "$(git status --porcelain)" ]; then | |
git commit -am 'apply swig updates' | |
git push | |
fi |