Skip to content

fix warnings

fix warnings #8

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
test:
name: Build and test
runs-on: ubuntu-latest
environment: Builder
steps:
- uses: actions/checkout@v4
- name: Set up Elixir
uses: erlef/setup-beam@v1
with:
elixir-version: '1.18.x'
otp-version: '26.x'
- name: Restore dependencies cache
uses: actions/cache@v3
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get
- name: Compile (warnings as errors)
run: mix compile --warnings-as-errors
- name: Install SQLite dependencies
run: |
sudo apt-get update
sudo apt-get install -y sqlite3 libsqlite3-dev
- name: Run tests with coverage
run: mix coveralls.github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
MIX_ENV: test
DISCORD_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
- name: Verify minimum coverage
run: |
COVERAGE=$(mix coveralls | grep "\[TOTAL\]" | awk '{print $2}' | sed 's/%//')
MINIMUM=40.0
if (( $(echo "$COVERAGE < $MINIMUM" | bc -l) )); then
echo "Test coverage is below minimum: $COVERAGE% < $MINIMUM%"
exit 1
else
echo "Coverage is $COVERAGE%, which meets the minimum requirement of $MINIMUM%"
fi
env:
DISCORD_TOKEN: ${{ secrets.DISCORD_BOT_TOKEN }}
- name: Run Credo
run: mix credo --strict
build-and-push:
needs: test
runs-on: ubuntu-latest
environment: Builder
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/soundbored:latest
${{ secrets.DOCKERHUB_USERNAME }}/soundbored:${{ github.sha }}
ghcr.io/${{ github.repository }}/soundbored:latest
ghcr.io/${{ github.repository }}/soundbored:${{ github.sha }}