aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/ci.yml
blob: 7d4defbb1a2a03d400e194469306bed86c9a9f6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
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=docker
  SBO_MAINTAINER_TOOLS_IMAGE: aclemons/sbo-maintainer-tools:0.9.0-15.0@sha256:a857eeb783622430a77ffdc0e9be0fa7d38b4d30696f362454eb990614a5ade8

jobs:
  changes:
    runs-on: ubuntu-22.04
    permissions:
      contents: read
    outputs:
      matrix: ${{ steps.set-matrix.outputs.matrix }}
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          show-progress: false
          fetch-depth: 2
          ref: ${{ github.head_ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}

      - name: Get slackbuild directories which have changes.
        id: changed-dirs
        uses: tj-actions/changed-files@90a06d6ba9543371ab4df8eeca0be07ca6054959 # v42.0.2
        with:
          base_sha: ${{ github.event.pull_request.base.sha }}
          dir_names: true
          dir_names_exclude_current_dir: true
          dir_names_max_depth: 2
          json: true
          quotepath: false
          files_ignore: .github/**

      - name: List all changed files
        run: echo '${{ steps.changed-dirs.outputs.all_changed_files }}'

      - name: Get matrix output
        id: set-matrix
        run: |
          {
            printf 'matrix<<SLACKBUILDS\n'
            jq -r -c 'map({dir: .})' <<< "${{ steps.changed-dirs.outputs.all_changed_files }}"
            printf 'SLACKBUILDS\n'
          } >> "$GITHUB_OUTPUT"

  sbolint:
    name: Checks with sbolint
    runs-on: ubuntu-22.04
    permissions:
      contents: read
      pull-requests: write
    needs: [changes]
    strategy:
      matrix:
        include: ${{ fromJSON(needs.changes.outputs.matrix) }}
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          show-progress: false
          ref: ${{ github.head_ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}

      - name: Run sbolint
        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: Comment with sbolint results
        uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
        with:
          issue-number: ${{ github.event.number }}
          body-path: comment-output