181 lines
5.9 KiB
YAML
181 lines
5.9 KiB
YAML
---
|
|
name: PR checks
|
|
|
|
"on":
|
|
pull_request_target:
|
|
types:
|
|
- opened
|
|
- synchronize
|
|
- reopened
|
|
|
|
concurrency:
|
|
group: ci-${{ github.event.number }}
|
|
cancel-in-progress: false
|
|
|
|
env:
|
|
# renovate: datasource=docker depName=aclemons/sbo-maintainer-tools versioning=loose
|
|
SBO_MAINTAINER_TOOLS_IMAGE: aclemons/sbo-maintainer-tools:0.9.3-15.0@sha256:e617db2c7de01f7a5778b7139439fc99a69715ba5ea573a7b0e2add34155f455
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
outputs:
|
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
|
steps:
|
|
- name: Calculate clone depth.
|
|
run: printf "CHECKOUT_FETCH_DEPTH=%s\n" "$(( ${{ github.event.pull_request.commits }} + 1 ))" >> "${GITHUB_ENV}"
|
|
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
show-progress: false
|
|
fetch-depth: ${{ env.CHECKOUT_FETCH_DEPTH }}
|
|
ref: ${{ github.head_ref }}
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
|
|
|
- name: Get slackbuild directories which have changes.
|
|
run: |
|
|
CHANGED_FILES="$(git diff-tree --name-only --diff-filter=d --no-commit-id -r ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | sed '/^\./d' | sed -n '/[^\/][^\/]*\/[^\/][^\/]*\//p' | xargs -I xx dirname xx | sort -u | sed '/.github/d' | sed 's/^/"/;s/$/"/g' | paste -d, -s | sed 's/^/[/;s/$/]/')"
|
|
|
|
delimiter="$(openssl rand -hex 8)"
|
|
printf "CHANGED_FILES<<%s\n" "$delimiter" >> "$GITHUB_ENV"
|
|
|
|
printf "%s\n" "$CHANGED_FILES" | tee -a "$GITHUB_ENV"
|
|
|
|
printf "%s\n" "$delimiter" >> "$GITHUB_ENV"
|
|
|
|
- name: Get matrix output
|
|
id: set-matrix
|
|
run: |
|
|
{
|
|
printf 'matrix<<SLACKBUILDS\n'
|
|
jq -r -c 'map({dir: .})' <<< "$CHANGED_FILES"
|
|
printf 'SLACKBUILDS\n'
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
sbolint:
|
|
name: Checks with sbolint
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
needs: [changes]
|
|
strategy:
|
|
matrix:
|
|
include: ${{ fromJSON(needs.changes.outputs.matrix) }}
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
show-progress: false
|
|
ref: ${{ github.head_ref }}
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
|
|
|
- name: Run sbolint
|
|
env:
|
|
MATRIX_DIR: ${{ matrix.dir }}
|
|
run: |
|
|
docker pull ${{ env.SBO_MAINTAINER_TOOLS_IMAGE }}
|
|
|
|
mkfifo pipe
|
|
tee sbolint-output < pipe &
|
|
set +e
|
|
|
|
docker run --rm -v "$(pwd):/work" -w /work ${{ env.SBO_MAINTAINER_TOOLS_IMAGE }} sbolint "$MATRIX_DIR" > pipe 2>&1
|
|
|
|
sbolint_status="$?"
|
|
set -e
|
|
|
|
{
|
|
if [[ "$sbolint_status" -eq 0 ]] ; then
|
|
printf '#### ✅ sbolint - %s ✅\n\n' "$MATRIX_DIR"
|
|
else
|
|
printf '#### ⛔️ sbolint - %s ⛔️\n\n' "$MATRIX_DIR"
|
|
fi
|
|
|
|
printf '```\n'
|
|
cat sbolint-output
|
|
rm sbolint-output
|
|
printf '```\n'
|
|
} > comment-output
|
|
shell:
|
|
bash
|
|
|
|
- name: Find Comment
|
|
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
|
|
id: fc
|
|
with:
|
|
issue-number: ${{ github.event.number }}
|
|
comment-author: 'github-actions[bot]'
|
|
body-includes: "sbolint - ${{ matrix.dir }}"
|
|
|
|
- name: Comment with sbolint results
|
|
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
|
|
with:
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
issue-number: ${{ github.event.number }}
|
|
body-path: comment-output
|
|
edit-mode: replace
|
|
|
|
dependencies:
|
|
name: Compute reverse dependencies
|
|
runs-on: ubuntu-24.04
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
needs: [changes]
|
|
strategy:
|
|
matrix:
|
|
include: ${{ fromJSON(needs.changes.outputs.matrix) }}
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
with:
|
|
show-progress: false
|
|
ref: ${{ github.head_ref }}
|
|
repository: ${{ github.event.pull_request.head.repo.full_name }}
|
|
|
|
- name: Get short package name
|
|
run: printf '%s\n' "$MATRIX_DIR" | cut -d/ -f2 | sed 's/^/PACKAGE_NAME=/' >> "$GITHUB_ENV"
|
|
env:
|
|
MATRIX_DIR: ${{ matrix.dir }}
|
|
|
|
- name: Look up dependencies
|
|
id: get_deps
|
|
uses: fjogeleit/http-request-action@23ad54bcd1178fcff6a0d17538fa09de3a7f0a4d # v1.16.4
|
|
with:
|
|
url: 'https://slackbuilds.org/revdeps.php?q=${{ env.PACKAGE_NAME }}'
|
|
method: 'GET'
|
|
preventFailureOnNoResponse: "true"
|
|
|
|
- name: Build comment
|
|
env:
|
|
MATRIX_DIR: ${{ matrix.dir }}
|
|
DEP_RESPONSE: ${{ steps.get_deps.outputs.response }}
|
|
run: |
|
|
{
|
|
printf '#### reverse dependencies - %s\n\n' "$MATRIX_DIR"
|
|
if [[ "$DEP_RESPONSE" == '""' ]] ; then
|
|
printf 'None\n'
|
|
else
|
|
printf '%s' "$DEP_RESPONSE" | sed 's/\\n/\n/g' | sed 's/^"//' | sort | sed 's/^/- [ ] /'
|
|
fi
|
|
} > comment-output
|
|
shell:
|
|
bash
|
|
|
|
- name: Find Comment
|
|
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0
|
|
id: fc
|
|
with:
|
|
issue-number: ${{ github.event.number }}
|
|
comment-author: 'github-actions[bot]'
|
|
body-includes: "reverse dependencies - ${{ matrix.dir }}"
|
|
|
|
- name: Comment with dependency results
|
|
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
|
|
with:
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
issue-number: ${{ github.event.number }}
|
|
body-path: comment-output
|
|
edit-mode: replace
|