From ce68860175c898fe98c580e1ce3fbbb4a8b64f18 Mon Sep 17 00:00:00 2001 From: Huy Nguyen Date: Fri, 7 Nov 2025 20:43:12 +1030 Subject: [PATCH] First attempt with workflows --- .gitea/workflows/build-and-push.yaml | 90 ++++++++++++++++++++++++++++ .gitea/workflows/ci.yaml | 70 ++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 .gitea/workflows/build-and-push.yaml create mode 100644 .gitea/workflows/ci.yaml diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml new file mode 100644 index 0000000..a495ad3 --- /dev/null +++ b/.gitea/workflows/build-and-push.yaml @@ -0,0 +1,90 @@ +name: Build & Push Docker image + +on: + # Trigger on pushes to main or release branches, and on manual workflow dispatch + push: + branches: + - main + - 'release/**' + - 'beta/**' + workflow_dispatch: + +jobs: + build-and-push: + runs-on: ubuntu-latest + environment: production + steps: + + # ------------------------------------------------------------------ + # 1. Checkout repository + # ------------------------------------------------------------------ + - name: Checkout source + uses: actions/checkout@v4 + with: + fetch-depth: 0 # needed for git rev‑parse and tag generation + + # ------------------------------------------------------------------ + # 2. Set up Docker Buildx (optional, but recommended for multi‑arch) + # ------------------------------------------------------------------ + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # ------------------------------------------------------------------ + # 3. Log in to the Gitea container registry + # ------------------------------------------------------------------ + - name: Log in to Gitea registry + uses: docker/login-action@v3 + with: + registry: ${{ secrets.REGISTRY_HOST }} # e.g. registry.example.com + username: ${{ secrets.REGISTRY_USER }} # e.g. admin + password: ${{ secrets.REGISTRY_PASSWORD }} # e.g. + + # ------------------------------------------------------------------ + # 4. Build the Docker image + # ------------------------------------------------------------------ + - name: Build image + id: build + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + # do not push yet + push: false + tags: | + ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:${{ github.sha }} + ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:${{ github.ref_name }} + ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:latest + build-args: | + # Add any build args here + # ARG_NAME=VALUE + + # ------------------------------------------------------------------ + # 5. Push the image to the registry + # ------------------------------------------------------------------ + - name: Push image + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile + push: true + tags: | + ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:${{ github.sha }} + ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:${{ github.ref_name }} + ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:latest + + # ------------------------------------------------------------------ + # 6. (Optional) Clean up local Docker cache + # ------------------------------------------------------------------ + - name: Docker system prune + run: docker system prune -f + if: ${{ always() }} + + # ------------------------------------------------------------------ + # 7. Output useful info + # ------------------------------------------------------------------ + - name: Show pushed image tags + run: | + echo "Pushed image tags:" + echo "- ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:${{ github.sha }}" + echo "- ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:${{ github.ref_name }}" + echo "- ${{ secrets.REGISTRY_HOST }}/${{ github.repository }}:latest" \ No newline at end of file diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..a5a5f20 --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,70 @@ +name: ci + +on: [push, pull_request] + +jobs: + build_linux: + runs-on: ubuntu-latest + defaults: + run: + shell: bash + # Use container with docker installed + container: + image: catthehacker/ubuntu:act-latest + strategy: + fail-fast: true + max-parallel: 4 + matrix: + config: + - { name: g++15, image: fir.love.io:3005/amd64/gcc1511, cc: /usr/bin/gcc, cxx: /usr/bin/g++, build_type: Debug, cppstd: 17 } + - { name: g++15, image: fir.love.io:3005/amd64/gcc1511, cc: /usr/bin/gcc, cxx: /usr/bin/g++, build_type: Release, cppstd: 17 } + - { name: clang15, image: fir.love.io:3005/amd64/clang15, cc: /usr/bin/clang-15, cxx: /usr/bin/clang++-15, build_type: Debug, cppstd: 17 } + - { name: clang17, image: fir.love.io:3005/amd64/clang17, cc: /usr/bin/clang-17, cxx: /usr/bin/clang++-17, build_type: Debug, cppstd: 17 } + - { name: clang18, image: fir.love.io:3005/amd64/clang18, cc: /usr/bin/clang-18, cxx: /usr/bin/clang++-18, build_type: Debug, cppstd: 17 } + - { name: clang19, image: fir.love.io:3005/amd64/clang19, cc: /usr/bin/clang-19, cxx: /usr/bin/clang++-19, build_type: Debug, cppstd: 17 } + - { name: clang20, image: fir.love.io:3005/amd64/gcc1511, cc: /usr/bin/clang, cxx: /usr/bin/clang++, build_type: Debug, cppstd: 17 } + - { name: clang20, image: fir.love.io:3005/amd64/gcc1511, cc: /usr/bin/clang, cxx: /usr/bin/clang++, build_type: Release, cppstd: 17 } + - { name: asan, image: fir.love.io:3005/amd64/gcc1511, cc: /usr/bin/gcc, cxx: /usr/bin/g++, build_type: asan, cppstd: 17 } + - { name: tsan, image: fir.love.io:3005/amd64/gcc1511, cc: /usr/bin/gcc, cxx: /usr/bin/g++, build_type: tsan, cppstd: 17 } + - { name: ubsan, image: fir.love.io:3005/amd64/gcc1511, cc: /usr/bin/gcc, cxx: /usr/bin/g++, build_type: ubsan, cppstd: 17 } + - { name: g++9.4.0, image: fir.love.io:3005/amd64/gcc940, cc: /opt/gcc940/bin/gcc, cxx: /opt/gcc940/bin/g++, build_type: Debug, cppstd: 17 } + - { name: g++10.3.0, image: fir.love.io:3005/amd64/gcc1030, cc: /opt/gcc1030/bin/gcc, cxx: /opt/gcc1030/bin/g++, build_type: Debug, cppstd: 17 } + - { name: g++11.3.0, image: fir.love.io:3005/amd64/gcc1130, cc: /opt/gcc1130/bin/gcc, cxx: /opt/gcc1130/bin/g++, build_type: Debug, cppstd: 17 } + - { name: g++12.3.0, image: fir.love.io:3005/amd64/gcc1230, cc: /opt/gcc1230/bin/gcc, cxx: /opt/gcc1230/bin/g++, build_type: Debug, cppstd: 20 } + - { name: g++13.3.0, image: fir.love.io:3005/amd64/gcc1330, cc: /opt/gcc1330/bin/gcc, cxx: /opt/gcc1330/bin/g++, build_type: Debug, cppstd: 20 } + - { name: g++14.3.0, image: fir.love.io:3005/amd64/gcc1430, cc: /opt/gcc1430/bin/gcc, cxx: /opt/gcc1430/bin/g++, build_type: Debug, cppstd: 20 } + + name: "${{ matrix.config.name}} (C++${{ matrix.config.cppstd }}, ${{ matrix.config.build_type }})" + steps: + - uses: actions/checkout@v3 + - name: Build + uses: https://github.com/addnab/docker-run-action@v3 + with: + image: ${{ matrix.config.image }} + options: --rm --volumes-from=${{ env.JOB_CONTAINER_NAME }} --pull always -v /home/vcpkg:/home/vcpkg + run: | + cd ${{ gitea.workspace }} + export VCPKG_DEFAULT_BINARY_CACHE=/home/vcpkg + ./build.sh -cc=${{ matrix.config.cc }} --cxx=${{ matrix.config.cxx }} --vcpkg --cmake="-DCMAKE_BUILD_TYPE=${{ matrix.config.cppstd }} -DCMAKE_CXX_STD=${{ matrix.config.cppstd }} -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON" + + results: + runs-on: ubuntu-latest + if: always() + needs: build_linux + steps: + - name: Report failure + if: failure() + uses: tsickert/discord-webhook@v5.4.0 + with: + webhook-url: ${{ secrets.WEBHOOK_URL }} + username: Gitea + avatar-url: https://about.gitea.com/gitea-text.svg + content: "Repo ${{ gitea.repository }} branch ${{ gitea.ref }} build :x:" + - name: Report success + if: success() + uses: tsickert/discord-webhook@v5.4.0 + with: + webhook-url: ${{ secrets.WEBHOOK_URL }} + username: Gitea + avatar-url: https://about.gitea.com/gitea-text.svg + content: "Repo ${{ gitea.repository }} branch ${{ gitea.ref }} build :white_check_mark:" \ No newline at end of file