]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
CI: test crossbuild and building Docker images
authorMatthew Newton <matthew-git@newtoncomputing.co.uk>
Tue, 23 Apr 2024 21:40:34 +0000 (22:40 +0100)
committerMatthew Newton <matthew-git@newtoncomputing.co.uk>
Wed, 1 May 2024 23:05:18 +0000 (00:05 +0100)
.github/workflows/crossbuild.yml [new file with mode: 0644]
.github/workflows/docker.yml [new file with mode: 0644]

diff --git a/.github/workflows/crossbuild.yml b/.github/workflows/crossbuild.yml
new file mode 100644 (file)
index 0000000..0de724f
--- /dev/null
@@ -0,0 +1,91 @@
+name: Check Crossbuild
+
+on:
+  push:
+    branches-ignore:
+      - coverity_scan
+  workflow_dispatch:
+
+env:
+  CI: 1
+  GH_ACTIONS: 1
+  DEBIAN_FRONTEND: noninteractive
+  APT_OPTS: "-y --no-install-recommends"
+
+jobs:
+  #
+  #  Generate matrix based on crossbuild docker directories.
+  #
+  gen-matrix:
+
+    runs-on: ubuntu-latest
+
+    outputs:
+      matrix: ${{ steps.gen-matrix.outputs.matrix }}
+
+    steps:
+
+    - uses: actions/checkout@v4
+      with:
+        lfs: false
+
+    - id: gen-matrix
+      name: Generate matrix based on crossbuild targets
+      run: |
+        cd scripts/docker/build
+        M=$(ls | perl -n -e '{chomp; push @L,"\"$_\""} END{print "{\"env\":[{\"OS\":",join("},{\"OS\":",@L),"}]}"}')
+        echo "Matrix: $M"
+        echo matrix=$M >> $GITHUB_OUTPUT
+
+  #
+  #  Run crossbuild target for each given OS. This will build the
+  #  Docker image and run `make test` inside.
+  #
+  crossbuild:
+    needs:
+      - gen-matrix
+
+    runs-on: ubuntu-20.04
+
+    strategy:
+      fail-fast: false
+      matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
+
+    env: ${{ matrix.env }}
+
+    name: "v4.0.x-${{ matrix.env.OS }}"
+
+    steps:
+
+    - uses: actions/checkout@v4
+      with:
+        fetch-depth: 0${{ ( matrix.env.OS != 'centos7' ) && '1' }}
+
+    - name: Run crossbuild tests
+      run: |
+        make crossbuild.$OS
+
+    - name: Show build log
+      if: ${{ success() || failure() }}
+      run: |
+        cat scripts/docker/crossbuild/build.$OS
+
+    - name: Show configure log
+      if: ${{ success() || failure() }}
+      run: |
+        cat scripts/docker/crossbuild/configure.$OS
+
+    - name: Show test log
+      if: ${{ success() || failure() }}
+      run: |
+        cat scripts/docker/crossbuild/log.$OS
+
+    #
+    #  If the CI has failed and the branch is ci-debug then start a tmate
+    #  session. SSH rendezvous point is emited continuously in the job output.
+    #
+    - name: "Debug: Start tmate"
+      uses: mxschmitt/action-tmate@v3
+      with:
+        limit-access-to-actor: true
+      if: ${{ github.ref == 'refs/heads/ci-debug' && failure() }}
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
new file mode 100644 (file)
index 0000000..4f7b6c9
--- /dev/null
@@ -0,0 +1,81 @@
+name: Build Dockerfiles
+
+on:
+  push:
+    branches-ignore:
+      - coverity_scan
+  workflow_dispatch:
+
+env:
+  CI: 1
+  GH_ACTIONS: 1
+  DEBIAN_FRONTEND: noninteractive
+  APT_OPTS: "-y --no-install-recommends"
+
+jobs:
+  #
+  #  Generate matrix based on docker directories.
+  #
+  gen-matrix:
+
+    runs-on: ubuntu-latest
+
+    outputs:
+      matrix: ${{ steps.gen-matrix.outputs.matrix }}
+
+    steps:
+
+    - uses: actions/checkout@v4
+      with:
+        lfs: false
+
+    - id: gen-matrix
+      name: Generate matrix based on docker targets
+      run: |
+        cd scripts/docker/build
+        M=$(ls | perl -n -e '{chomp; push @L,"\"$_\""} END{print "{\"env\":[{\"OS\":",join("},{\"OS\":",@L),"}]}"}')
+        echo "Matrix: $M"
+        echo matrix=$M >> $GITHUB_OUTPUT
+
+  #
+  #  Run docker target for each given OS. This will build the
+  #  Docker image.
+  #
+  docker:
+    needs:
+      - gen-matrix
+
+    runs-on: ubuntu-20.04
+
+    strategy:
+      fail-fast: false
+      matrix: ${{ fromJson(needs.gen-matrix.outputs.matrix) }}
+
+    env: ${{ matrix.env }}
+
+    name: "v4.0.x-${{ matrix.env.OS }}"
+
+    steps:
+
+    - uses: actions/checkout@v4
+      with:
+        fetch-depth: 1
+
+    - name: Regenerate Dockerfile
+      run: |
+        rm scripts/docker/build/$OS/Dockerfile || true
+        make docker.$OS.regen
+
+    - name: Build docker image
+      run: |
+        make docker.$OS.build
+
+    #
+    #  If the CI has failed and the branch is ci-debug then start a tmate
+    #  session. SSH rendezvous point is emited continuously in the job output.
+    #
+    - name: "Debug: Start tmate"
+      uses: mxschmitt/action-tmate@v3
+      with:
+        limit-access-to-actor: true
+      if: ${{ github.ref == 'refs/heads/ci-debug' && failure() }}