Skip to content

Commit

Permalink
Add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
reachfh committed Oct 8, 2023
1 parent 92478f3 commit d8c1cc3
Showing 1 changed file with 103 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
name: Test
on:
push:
branches:
- "main"
pull_request:
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
otp: ['24.3', '25.2', '26.1.1']
elixir: ['1.13.4', '1.14.5', '1.15.6']

env:
MIX_ENV: test

steps:
- name: Cancel previous runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

- name: Check out source
uses: actions/checkout@v3

- name: Install Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{matrix.otp}}
elixir-version: ${{matrix.elixir}}

- name: Check formatting
run: mix format --check-formatted

- name: Cache deps
id: cache-deps
uses: actions/cache@v3
env:
cache-name: cache-elixir-deps
with:
path: deps
key: ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-mix-${{ env.cache-name }}-
- name: Cache compiled build
id: cache-build
uses: actions/cache@v3
env:
cache-name: cache-compiled-build
with:
path: _build
key: ${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-${{matrix.otp}}-${{matrix.elixir}}-mix-${{ env.cache-name }}-
- name: Install tools
run: mix do local.rebar --force, local.hex --force

- name: Get Elixir deps
run: mix deps.get

- name: Compile
run: mix compile --warnings-as-errors

- name: Run tests
run: mix test

- name: Run credo
# run: mix credo --mute-exit-status
run: mix credo

- name: Run hex.audit
run: mix hex.audit

- name: Run deps.audit
run: mix deps.audit

- name: Run dialyzer
run: mix dialyzer --format github

- name: Publish unit test results to GitHub
uses: EnricoMi/publish-unit-test-result-action@v2
# Run even if tests fail
if: always()
with:
junit_files: _build/test/junit-reports/*.xml
# junit_files: _build/test/lib/*/*.xml
check_name: "Test Results ${{matrix.elixir}} ${{matrix.otp}}"

# - name: Upload results to Datadog
# if: always()
# continue-on-error: true
# env:
# DD_API_KEY: ${{ secrets.ACTIONS_DD_API_KEY }}
# DD_ENV: ci
# run: |
# npm install -g @datadog/datadog-ci
# datadog-ci junit upload --service api-graphql _build/test/lib/*/test-junit-report.xml

0 comments on commit d8c1cc3

Please sign in to comment.