From a2b24344458e204ec688dcff9c4d2aeb06bf652a Mon Sep 17 00:00:00 2001 From: javalsai Date: Fri, 6 Sep 2024 20:28:35 +0200 Subject: [PATCH] ci: lots of ci features --- .github/actions/build/action.yml | 54 ------------ .github/workflows/build-check.yml | 65 --------------- .github/workflows/check-and-build.yml | 113 ++++++++++++++++++++++++++ .github/workflows/make-release.yml | 39 +++++++++ .github/workflows/push.yml | 91 ++------------------- .github/workflows/release.yml | 56 ------------- assets/pkg/aur/make-srcinfo.sh | 2 +- 7 files changed, 159 insertions(+), 261 deletions(-) delete mode 100644 .github/actions/build/action.yml delete mode 100644 .github/workflows/build-check.yml create mode 100644 .github/workflows/check-and-build.yml create mode 100644 .github/workflows/make-release.yml delete mode 100644 .github/workflows/release.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml deleted file mode 100644 index 08bf283..0000000 --- a/.github/actions/build/action.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Build Project - -on: - workflow_call: - -# TODO: make arch_name optional (dont upload artifact) -inputs: - arch_name: - description: "Architecture Name" - required: true - cc: - description: "The compiler to use" - required: false - default: "gcc" - cflags: - description: "Compiler flags" - required: false - default: "" - - -runs: - using: "composite" - - steps: - - uses: actions/checkout@v4 - - # cache-apt-pkgs-action try to cache :i386 packages challenge impossible - - if: ${{ inputs.arch_name == 'x86' }} - shell: bash - run: | - sudo dpkg --add-architecture i386 - sudo apt-get update -y - sudo apt-get install -y libpam0g-dev:i386 - - - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: "libpam0g-dev gcc-multilib" - version: 1.0 - - - name: Build Code - shell: bash - run: | - make CC=${{ inputs.cc }} CFLAGS="-O3 ${{ inputs.cflags }}" \ - 2> stderr-${{ inputs.arch_name }} - mv lidm lidm-${{ inputs.arch_name }} - - - name: Upload Artifact - uses: actions/upload-artifact@v4 - with: - name: build-${{ inputs.arch_name }} - path: | - lidm-${{ inputs.arch_name }} - stderr-${{ inputs.arch_name }} - retention-days: 1 diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml deleted file mode 100644 index 1ba7860..0000000 --- a/.github/workflows/build-check.yml +++ /dev/null @@ -1,65 +0,0 @@ -name: Test Build - -on: push - -jobs: - check_build: - permissions: write-all - strategy: - matrix: - include: - - arch_name: x86_64 - cc: gcc - cflags: - - arch_name: x86 - cc: gcc - cflags: -m32 - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: myrotvorets/set-commit-status-action@master - with: - token: ${{ secrets.GITHUB_TOKEN }} - status: pending - context: Build (${{ matrix.arch_name }}) - - - name: Attempt Build (${{ matrix.arch_name }}) - uses: ./.github/actions/build - with: - arch_name: ${{ matrix.arch_name }} - cc: ${{ matrix.cc }} - cflags: "-Wall ${{ matrix.cflags }}" - - - name: Download Build Results - uses: actions/download-artifact@v4 - with: - name: build-${{ matrix.arch_name }} - path: build-results - - - name: Process Results - id: get-stats - if: always() - run: | - if ! [ -d "build-results" ]; then - # Build failed - echo "DESCR=" >> "$GITHUB_OUTPUT" - else - # Build Succeeded - cd "build-results" - ls -lah - cat stderr-* >&2 - WARNS="$(cat stderr-* | grep '^[^ ]*\.[ch]:' | wc -l)" - HSIZE="$(stat --printf="%s" lidm-* | numfmt --to=iec-i)B" - - echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" - fi - - - name: Set final commit status - uses: myrotvorets/set-commit-status-action@master - if: always() - with: - token: ${{ secrets.GITHUB_TOKEN }} - status: ${{ job.status }} - context: Build (${{ matrix.arch_name }}) - description: ${{ steps.get-stats.outputs.DESCR }} diff --git a/.github/workflows/check-and-build.yml b/.github/workflows/check-and-build.yml new file mode 100644 index 0000000..b99987c --- /dev/null +++ b/.github/workflows/check-and-build.yml @@ -0,0 +1,113 @@ +name: Check and Build + +on: + workflow_call: + inputs: + set-statuses: + required: false + default: true + type: boolean + +jobs: + spellcheck: + name: Check Grammar + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "codespell" + version: 1.0 + - run: codespell + + shellcheck: + name: Shell Check + runs-on: ubuntu-24.04 + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "shellcheck" + version: 1.0 + - run: find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*' | xargs shellcheck + + build-linux-amd64: + name: Build for amd64 + runs-on: ubuntu-24.04 + permissions: write-all + needs: [spellcheck, shellcheck] + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "libpam0g-dev" + version: 1.0 + - id: build + run: | + make CFLAGS="-O3 -Wall" 2> /tmp/stderr + cat /tmp/stderr >&2 + + HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B" + WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)" + mv lidm lidm-amd64 + + echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" + + - uses: myrotvorets/set-commit-status-action@master + if: inputs.set-statuses + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + description: ${{ steps.build.outputs.DESCR }} + context: Build for amd64 + + - uses: actions/upload-artifact@v4 + with: + name: build-amd64 + path: lidm-amd64 + retention-days: 1 + + build-linux-i386: + name: Build for i386 + runs-on: ubuntu-24.04 + permissions: write-all + needs: [spellcheck, shellcheck] + + steps: + - uses: actions/checkout@v4 + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: "libpam0g-dev gcc-multilib" + version: 1.0 + - run: | + sudo dpkg --add-architecture i386 + sudo apt-get update -y + sudo apt-get install -y libpam0g-dev:i386 + + - id: build + run: | + make CFLAGS="-O3 -Wall -m32" 2> /tmp/stderr + cat /tmp/stderr >&2 + + HSIZE="$(stat --printf="%s" lidm | numfmt --to=iec-i)B" + WARNS="$(cat /tmp/stderr | grep '^[^ ]*\.[ch]:' | wc -l)" + mv lidm lidm-i386 + + echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" + + - uses: myrotvorets/set-commit-status-action@master + if: inputs.set-statuses + with: + token: ${{ secrets.GITHUB_TOKEN }} + status: ${{ job.status }} + description: ${{ steps.build.outputs.DESCR }} + context: Build for i386 + + - uses: actions/upload-artifact@v4 + with: + name: build-i386 + path: lidm-i386 + retention-days: 1 diff --git a/.github/workflows/make-release.yml b/.github/workflows/make-release.yml new file mode 100644 index 0000000..2a229ae --- /dev/null +++ b/.github/workflows/make-release.yml @@ -0,0 +1,39 @@ +name: Check and Build Release + +on: + workflow_dispatch: + inputs: + version: + required: true + default: '' + type: string + +jobs: + build: + name: Check and Build + uses: ./.github/workflows/check-and-build.yml + permissions: write-all + with: + set-statuses: false + + release: + name: Make Release v${{ inputs.version }} + runs-on: ubuntu-24.04 + permissions: write-all + needs: build + steps: + - uses: actions/download-artifact@v4 + with: + path: builds + pattern: build-* + merge-multiple: true + + - uses: ncipollo/release-action@v1 + with: + tag: v${{ inputs.version }} + commit: ${{ github.sha }} + artifacts: builds/lidm-* + artifactsErrorsFailBuild: true + body: Release notes not generated yet. + + # TODO: get checksums and commit new AUR pkgbuilds diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index a9c833d..db871fd 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -1,89 +1,10 @@ -name: Test Build +name: Push Checks -on: push +on: + push jobs: - spellcheck: - name: Check Grammar - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: "codespell" - version: 1.0 - - run: codespell - - shellcheck: - name: Shell Check - runs-on: ubuntu-latest - - steps: - - uses: actions/check_build@v4 - - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: "shellcheck" - version: 1.0 - - run: shellcheck -P $(find . -type f -name '*.sh' -not -path './assets/pkg/aur/*/src/*') - - check_build: + check-and-build: + name: Check and Build + uses: ./.github/workflows/check-and-build.yml permissions: write-all - strategy: - matrix: - include: - - arch_name: x86_64 - cc: gcc - cflags: - - arch_name: x86 - cc: gcc - cflags: -m32 - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: myrotvorets/set-commit-status-action@master - with: - token: ${{ secrets.GITHUB_TOKEN }} - status: pending - context: Build (${{ matrix.arch_name }}) - - - name: Attempt Build (${{ matrix.arch_name }}) - uses: ./.github/actions/build - with: - arch_name: ${{ matrix.arch_name }} - cc: ${{ matrix.cc }} - cflags: "-Wall ${{ matrix.cflags }}" - - - name: Download Build Results - uses: actions/download-artifact@v4 - with: - name: build-${{ matrix.arch_name }} - path: build-results - - - name: Process Results - id: get-stats - if: always() - run: | - if ! [ -d "build-results" ]; then - # Build failed - echo "DESCR=" >> "$GITHUB_OUTPUT" - else - # Build Succeeded - cd "build-results" - ls -lah - cat stderr-* >&2 - WARNS="$(cat stderr-* | grep '^[^ ]*\.[ch]:' | wc -l)" - HSIZE="$(stat --printf="%s" lidm-* | numfmt --to=iec-i)B" - - echo "DESCR='$HSIZE, $WARNS warnings'" >> "$GITHUB_OUTPUT" - fi - - - name: Set final commit status - uses: myrotvorets/set-commit-status-action@master - if: always() - with: - token: ${{ secrets.GITHUB_TOKEN }} - status: ${{ job.status }} - context: Build (${{ matrix.arch_name }}) - description: ${{ steps.get-stats.outputs.DESCR }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index b3330cf..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Build for Release - -on: - release: - types: [created] - -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - include: - - arch_name: x86_64 - cc: gcc - cflags: - - arch_name: x86 - cc: gcc - cflags: -m32 - - steps: - - uses: actions/checkout@v4 - - name: Build Project - uses: ./.github/actions/build - with: - arch_name: ${{ matrix.arch_name }} - cc: ${{ matrix.cc }} - cflags: ${{ matrix.cflags }} - - upload: - permissions: write-all - runs-on: ubuntu-latest - needs: build - steps: - - uses: actions/checkout@v4 - - name: Merge Build Artifacts - uses: actions/upload-artifact/merge@v4 - with: - name: all-builds - pattern: build-* - delete-merged: true - retention-days: 1 - - - uses: actions/download-artifact@v4 - with: - name: all-builds - path: builds - - - name: Upload Builds to Release - run: | - cd builds - for file in ./*; do - echo "Uploading $file..." - gh release upload ${{ github.event.release.tag_name }} "$file" --clobber - done - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/assets/pkg/aur/make-srcinfo.sh b/assets/pkg/aur/make-srcinfo.sh index bc700c4..6739191 100755 --- a/assets/pkg/aur/make-srcinfo.sh +++ b/assets/pkg/aur/make-srcinfo.sh @@ -1,4 +1,4 @@ -#/usr/bin/env bash +#!/usr/bin/env bash set -e MYSELF=$(realpath "$0")