diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml deleted file mode 100644 index d2cf66c..0000000 --- a/.forgejo/workflows/build.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: Build and Push - -on: - push: - branches: - - main - -jobs: - build-and-push: - name: Build and Push Docker Image - runs-on: docker - - steps: - - name: Checkout code - uses: https://github.com/actions/checkout@v4 - - - name: Generate image tag - id: tag - run: | - TIMESTAMP=$(date +%s) - SHORT_SHA=$(git rev-parse --short=7 HEAD | cut -c1-7) - TAG="main-${TIMESTAMP}-${SHORT_SHA}" - echo "tag=${TAG}" >> $GITHUB_OUTPUT - - - name: Install Docker CLI - run: | - apt-get update && apt-get install -y docker.io - - - name: Build and Push - run: | - echo "${{ secrets.FORGEJO_TOKEN }}" | docker login git.mcintire.me -u graham --password-stdin - - docker build \ - -t "git.mcintire.me/graham/aprs.me:${{ steps.tag.outputs.tag }}" \ - -t "git.mcintire.me/graham/aprs.me:latest" \ - . - - docker push "git.mcintire.me/graham/aprs.me:${{ steps.tag.outputs.tag }}" - docker push "git.mcintire.me/graham/aprs.me:latest" diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml new file mode 100644 index 0000000..d8d4078 --- /dev/null +++ b/.forgejo/workflows/ci.yml @@ -0,0 +1,167 @@ +name: Elixir CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + quality: + name: Build and test + runs-on: ubuntu-latest + container: + image: debian:trixie-slim + services: + postgres: + image: postgis/postgis:17-3.5 + env: + POSTGRES_PASSWORD: postgres + POSTGRES_USER: postgres + POSTGRES_DB: aprsme_test + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U postgres" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + MIX_ENV: test + + steps: + - name: Install system packages + run: | + apt-get update + apt-get install -y --no-install-recommends git ca-certificates nodejs npm + rm -rf /var/lib/apt/lists/* + + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Elixir + uses: https://github.com/erlef/setup-beam@v1 + with: + version-type: strict + elixir-version: '1.20.2' + otp-version: '29.0' + + - name: Restore dependency and build caches + uses: https://code.forgejo.org/actions/cache@v4 + with: + path: | + deps + _build + key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix- + + - name: Install Hex and Rebar + run: | + mix local.hex --force + mix local.rebar --force + + - name: Fetch dependencies + run: mix deps.get + + - name: Check formatting + run: mix format --check-formatted + + - name: Compile (warnings as errors) + run: mix compile --warnings-as-errors + + - name: Run Credo + run: mix credo --strict + + - name: Run tests + run: mix test + + - name: Run Sobelow + run: mix sobelow --config + + - name: Run Hex Audit + run: mix hex.audit + + dialyzer: + name: Dialyzer + runs-on: ubuntu-latest + container: + image: debian:trixie-slim + env: + MIX_ENV: dev + + steps: + - name: Install system packages + run: | + apt-get update + apt-get install -y --no-install-recommends git ca-certificates nodejs npm + rm -rf /var/lib/apt/lists/* + + - name: Checkout + uses: https://code.forgejo.org/actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Elixir + uses: https://github.com/erlef/setup-beam@v1 + with: + version-type: strict + elixir-version: '1.20.2' + otp-version: '29.0' + + - name: Restore dependency and build caches + uses: https://code.forgejo.org/actions/cache@v4 + with: + path: | + deps + _build + key: ${{ runner.os }}-dialyzer-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-dialyzer- + + - name: Install Hex and Rebar + run: | + mix local.hex --force + mix local.rebar --force + + - name: Fetch dependencies + run: mix deps.get + + - name: Run Dialyzer + run: mix dialyzer + + build-and-push: + name: Build and Push Docker Image + runs-on: ubuntu-latest + needs: [quality, dialyzer] + if: github.event_name == 'push' + + steps: + - name: Checkout code + uses: https://code.forgejo.org/actions/checkout@v4 + with: + submodules: recursive + + - name: Generate image tag + id: tag + run: | + TIMESTAMP=$(date +%s) + SHORT_SHA=$(git rev-parse --short=7 HEAD | cut -c1-7) + TAG="main-${TIMESTAMP}-${SHORT_SHA}" + echo "tag=${TAG}" >> $GITHUB_OUTPUT + + - name: Install Docker CLI + run: | + apt-get update && apt-get install -y docker.io + + - name: Build and Push + run: | + echo "${{ secrets.FORGEJO_TOKEN }}" | docker login git.mcintire.me -u graham --password-stdin + docker build \ + -t "git.mcintire.me/graham/aprs.me:${{ steps.tag.outputs.tag }}" \ + -t "git.mcintire.me/graham/aprs.me:latest" \ + . + docker push "git.mcintire.me/graham/aprs.me:${{ steps.tag.outputs.tag }}" + docker push "git.mcintire.me/graham/aprs.me:latest"