summaryrefslogtreecommitdiff
path: root/.forgejo/workflows/lint.yml
blob: 702b3486134d9827f236bc38d5d40cad1f914ead (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
on:
  push:
    paths-ignore:
    - 'README.rst'
    - '.guix-authorizations'
    - '.guix-channel'
  pull_request:
    paths:
      - 'guix-science/packages/**'

jobs:
  lint-new-modified:
    name: Lint new/modified packages
    runs-on: guix
    steps:
      - run: |
          set -e
          set -o pipefail
          GUIX_COMMIT=$(guix shell git -- git ls-remote https://codeberg.org/guix/guix.git HEAD | cut -f 1)
          echo "(list (channel (name 'guix-science) (url \"${{ forge.event.pull_request.head.repo.clone_url }}\") (commit \"${{ forge.event.pull_request.head.sha }}\")) (channel (name 'guix) (url \"https://codeberg.org/guix/guix.git\") (commit \"$GUIX_COMMIT\") (introduction (make-channel-introduction \"9edb3f66fd807b096b48283debdcddccfea34bad\" (openpgp-fingerprint \"BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA\")))))" > channels-head.scm
          echo "(list (channel (name 'guix-science) (url \"${{ forge.event.pull_request.head.repo.clone_url }}\") (commit \"${{ forge.event.pull_request.merge_base }}\")) (channel (name 'guix) (url \"https://codeberg.org/guix/guix.git\") (commit \"$GUIX_COMMIT\") (introduction (make-channel-introduction \"9edb3f66fd807b096b48283debdcddccfea34bad\" (openpgp-fingerprint \"BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA\")))))" > channels-base.scm

          guix shell git -- git clone --depth=1 https://gitlab.inria.fr/guix-hpc/guix-extensions 2> /dev/null
          export GUIX_EXTENSIONS_PATH=$(pwd)/guix-extensions/guix/extensions
          # Hide time-machine STDERR
          export PACKAGES=$(guix time-machine -C channels-head.scm -- diff -r -C channels-base.scm 2> /dev/null)
          # Lint all packages at once
          if [[ -z "$PACKAGES" ]] ; then echo "No packages to lint" && exit 0 ; else echo "Linting $PACKAGES" ; export LINT="$(guix time-machine -C channels-head.scm -- lint -x archival $PACKAGES)" ; guix time-machine -C channels-head.scm -- lint -c archival $PACKAGES ; fi
          # Exit with error when lint writes on STDOUT.
          if [[ -z "$LINT" ]] ; then echo "No lint warning for packages $PACKAGES" ; else echo "$LINT" && exit 1 ; fi