Skip to content

[cap_project] Updates for several packages #1790

[cap_project] Updates for several packages

[cap_project] Updates for several packages #1790

Workflow file for this run

#
# This workflow is run for pull requests the modify the `packages` directory.
# It works in two stages: first it determines the list of added, modified or
# removed packages; for each added or modified package, it executes the
# `validate_package.py` script to check for issues with the metadata or
# tarball. Provided these initial tests pass, the second stage consists of
# invoking a separate workflow which runs tests for all packages in the
# package distribution as they would appear when the PR under review would be
# merged. This is used to determine whether any package tests change from PASS
# to FAIl or vice versa.
#
name: "PR"
on:
workflow_dispatch: # manual trigger for debugging
pull_request:
paths:
- 'packages/*/meta.json'
concurrency:
# group by workflow and ref
group: ${{ github.workflow }}-${{ github.ref }}
# Cancel intermediate builds, but only if it is a pull request build.
cancel-in-progress: true
jobs:
detect-changes:
name: "Detect affected packages"
runs-on: ubuntu-20.04
if: ${{ !contains( github.event.pull_request.labels.*.name, 'skip tests') }}
outputs:
modified: ${{ steps.modified.outputs.modified }}
steps:
# clone with depth 0, so that we can determine what was changed
# TODO: isn't depth 1 sufficient?
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: "Install package distribution tools"
run: python -m pip install -r tools/requirements.txt
# the following step is useful for debugging
- name: "Determine system architecture for -march=native"
run: |
echo "cc -march=native: $(tools/compiler_arch.sh cc)"
echo "c++ -march=native: $(tools/compiler_arch.sh c++)"
# Setup ccache, to speed up repeated compilation of the same binaries
# (i.e., GAP and the packages)
- name: "Setup ccache"
uses: Chocobo1/setup-ccache-action@v1
with:
update_packager_index: false
- name: "Install GAP"
uses: gap-actions/setup-gap@v2
with:
GAP_BOOTSTRAP: 'minimal'
GAP_PKGS_TO_CLONE: 'json'
GAP_PKGS_TO_BUILD: 'json'
- name: "Determine what was added or modified, validate"
id: modified
run: |
modified=$(git diff --name-only --no-renames --diff-filter=AM ${{ github.event.pull_request.base.sha }} -- packages/*/meta.json)
echo "Added or updated packages: ${modified}"
if [[ -n "${modified}" ]]; then
echo "modified=true" >> $GITHUB_OUTPUT
else
echo "modified=false" >> $GITHUB_OUTPUT
fi
echo "Obtain copies of old metadata, if any..."
for PKG in ${modified}; do
git cat-file blob ${{ github.event.pull_request.base.sha }}:$PKG > $PKG.old || rm -f $PKG.old
done
echo "Validate metadata..."
tools/validate_package.py ${modified}
test-all-master:
name: "master"
needs: detect-changes
if: ${{ needs.detect-changes.outputs.modified == 'true' }}
uses: ./.github/workflows/test-all.yml
with:
which-gap: 'master'
test-all-release:
name: "4.12.1"
needs: detect-changes
if: ${{ needs.detect-changes.outputs.modified == 'true' }}
uses: ./.github/workflows/test-all.yml
with:
which-gap: '4.12.1'
status-comment:
name: "Create or update PR comment"
runs-on: ubuntu-20.04
needs: test-all-master # TODO: also handle test-all-release
if: always()
steps:
- name: "Download report"
uses: actions/download-artifact@v3
with:
name: report-master
path: _report
- name: "Prepare report.md"
id: get-comment-body
run: |
echo "body<<EOF1234567890EOF" >> $GITHUB_OUTPUT
cat _report/report.md >> $GITHUB_OUTPUT
echo "EOF1234567890EOF" >> $GITHUB_OUTPUT
- name: "Find Comment"
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
# comment-author: "gap-package-distribution-bot <100730870+gap-package-distribution-bot[bot]@users.noreply.github.com>"
body-includes: "Package Evaluation Report"
# We set up a GitHub App in order to ensure that workflows are run on the PRs
# created by us, following the instructions here:
# <https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#authenticating-with-github-app-generated-tokens>
# The bot can also be set up for personal forks of this repository, for testing
# and debugging, see <https://github.com/apps/gap-package-distribution-bot>.
- uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
# TODO: extra work is needed to make the following work with pull requests
# that come from forks of this repository.
- name: "Create or update comment"
uses: peter-evans/create-or-update-comment@v2
with:
token: ${{ steps.generate-token.outputs.token }}
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.get-comment-body.outputs.body }}
edit-mode: replace