From f4d54a57c17553fb5d2c1673e0357003573c5b8a Mon Sep 17 00:00:00 2001 From: Jeff McKenzie Date: Thu, 7 Mar 2024 13:02:47 -0600 Subject: [PATCH] Add CI workflow --- .github/workflows/main.yml | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..cc290aa --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,68 @@ +name: CI + +on: + pull_request: + push: + branches: + - main + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MIX_ENV: test + +jobs: + test: + name: Test (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }}) + + runs-on: ubuntu-20.04 + + strategy: + fail-fast: false + matrix: + include: + - otp: "26.0" + elixir: "1.16" + lint: true + + steps: + - name: Clone the repository + uses: actions/checkout@v3 + + - name: Install Erlang/OTP and Elixir + uses: erlef/setup-beam@v1 + with: + otp-version: ${{ matrix.otp }} + elixir-version: ${{ matrix.elixir }} + + - name: Cache dependencies + id: cache-deps + uses: actions/cache@v3 + with: + path: | + deps + _build + key: | + ${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }} + restore-keys: | + ${{ runner.os }}-mix-otp${{ matrix.otp }}-elixir${{ matrix.elixir }}- + + - name: Install and compile dependencies + run: mix do deps.get, deps.compile + + - name: Check for unused dependencies + run: mix deps.unlock --check-unused + + - name: Check for compilation warnings + run: mix compile --force --warnings-as-errors + + - name: Ensure code is formatted + run: mix format --check-formatted + + - name: Ensure runtime types are correct + run: mix dialyzer + + - name: Check code consistency + run: mix credo --strict + + - name: Run tests + run: mix test