Skip to content

Operations contracts #132

Operations contracts

Operations contracts #132

Workflow file for this run

name: Contracts CI
on:
push:
branches: [main]
pull_request:
env:
ELIXIR_VERSION: 1.15.7
OTP_VERSION: 26
jobs:
elixir-deps:
name: Elixir dependencies (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }})
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- elixir: 1.15.7
otp: 26
- elixir: 1.14.3
otp: 25
- elixir: 1.13.4
otp: 22
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
env:
ImageOS: ubuntu20
- name: Retrieve Cached Dependencies
uses: actions/cache@v4
id: mix-cache
with:
path: |
elixir/deps
elixir/_build/test
elixir/priv/plts
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('elixir/mix.lock') }}
- name: Install Dependencies
if: steps.mix-cache.outputs.cache-hit != 'true'
working-directory: elixir
run: |
mkdir -p priv/plts
mix local.rebar --force
mix local.hex --force
mix deps.get
mix deps.compile --warnings-as-errors
mix dialyzer --plt
static-code-analysis-elixir:
name: Static Code Analysis elixir
needs: [elixir-deps]
runs-on: ubuntu-20.04
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
env:
ImageOS: ubuntu20
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@v4
id: mix-cache
with:
path: |
elixir/deps
elixir/_build/test
elixir/priv/plts
key: ${{ runner.os }}-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('elixir/mix.lock') }}
- name: Run Credo
working-directory: elixir
run: mix credo
- name: Check for unused dependencies
working-directory: elixir
run: mix deps.unlock --check-unused
- name: Check elixir Code Format
working-directory: elixir
run: ls -la && mix format --check-formatted
- name: Run Dialyzer
working-directory: elixir
run: mix dialyzer
check-elixir-contracts:
name: Check elixir contracts
needs: [elixir-deps]
runs-on: ubuntu-20.04
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
- name: Setup
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
env:
ImageOS: ubuntu20
- name: Retrieve Cached Dependencies
uses: actions/cache@v4
id: mix-cache
with:
path: |
elixir/deps
elixir/_build/test
elixir/priv/plts
key: ${{ runner.os }}-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('elixir/mix.lock') }}
- uses: arduino/setup-protoc@v1
with:
version: "3.20.1"
- name: Install protoc elixir plugin
run: mix escript.install --force hex protobuf
- name: Add escript bin folder to path
run: echo "$HOME/.mix/escripts" >> $GITHUB_PATH
- name: generate contracts
run: make elixir-generate
- name: Check for uncommitted schema changes
run: |
git add -N elixir/
git diff
git diff --quiet
- name: Git status
run: git status
check-go-contracts:
name: Check go contracts
runs-on: ubuntu-20.04
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.18
- uses: arduino/setup-protoc@v1
with:
version: "3.20.1"
- name: Install protoc gen go
run: go install google.golang.org/protobuf/cmd/[email protected]
- name: generate contracts
run: make go-generate
- name: Check for uncommitted schema changes
run: |
git add -N go/
git diff
git diff --quiet
- name: Git status
run: git status
test-golang:
name: Go test
needs: [check-go-contracts]
runs-on: ubuntu-20.04
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: 1.18
- name: Run golang tests
working-directory: go
run: go mod download && go test ./...
test-elixir:
name: Elixir test (Elixir ${{ matrix.elixir }}, OTP ${{ matrix.otp }})
needs: [elixir-deps, check-elixir-contracts]
runs-on: ubuntu-20.04
strategy:
matrix:
include:
- elixir: 1.14.3
otp: 25
- elixir: 1.13.4
otp: 22
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
uses: erlef/setup-beam@v1
with:
elixir-version: ${{ matrix.elixir }}
otp-version: ${{ matrix.otp }}
- name: Retrieve Cached Dependencies
uses: actions/cache@v4
id: mix-cache
with:
path: |
elixir/deps
elixir/_build/test
elixir/priv/plts
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('elixir/mix.lock') }}
- name: Compile
working-directory: elixir
run: mix compile --warnings-as-errors
- name: Run elixir test
working-directory: elixir
run: mix test --warnings-as-errors --color --trace --slowest 10