Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport a ton of changes #22

Merged
merged 18 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 160 additions & 9 deletions .github/workflows/main.yml
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added Dialyzer and linting to CI.

Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,169 @@ on:
branches:
- main
pull_request:


env:
MIX_ENV: test

jobs:
lint:
Jcambass marked this conversation as resolved.
Show resolved Hide resolved
name: Lint
runs-on: ubuntu-20.04

env:
ELIXIR_VERSION: "1.15"
OTP_VERSION: "26.1"

steps:
- name: Check out this repository
uses: actions/checkout@v4

- name: Install Erlang and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION}}

- name: Cache Mix compiled stuff
uses: actions/cache@v3
id: cache-mix
with:
path: |
_build
deps
key: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-

- name: Install dependencies
run: mix deps.get

- name: Check for unused dependencies
run: mix deps.unlock --check-unused

- name: Check for formatted code
run: mix format --check-formatted

dialyzer:
name: Dialyze
runs-on: ubuntu-20.04

env:
ELIXIR_VERSION: "1.15"
OTP_VERSION: "26.1"

steps:
- name: Check out this repository
uses: actions/checkout@v4

- name: Install Erlang and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION}}

- name: Cache Mix compiled stuff
uses: actions/cache@v3
id: cache-mix
with:
path: |
_build
deps
key: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-
mix-elixir${{ env.ELIXIR_VERSION }}-otp${{ env.OTP_VERSION }}-${{ hashFiles('mix.lock') }}-

# Don't cache PLTs based on mix.lock hash, as Dialyzer can incrementally update even old
# ones. Cache key based on Elixir and Erlang version (also useful when running in matrix).
- name: Cache Dialyzer's PLT
uses: actions/cache@v3
id: cache-plt
with:
path: plts
key: |
plt-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
plt-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-

- name: Install dependencies
run: mix deps.get

# Create PLTs if no cache was found
- name: Create PLTs
if: steps.cache-plt.outputs.cache-hit != 'true'
run: |
mkdir -p plts
mix dialyzer --plt

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

test:
name: Test (Erlang ${{ matrix.otp }}, Elixir ${{ matrix.elixir }}, Toxiproxy ${{ matrix.toxiproxy }})

runs-on: ubuntu-20.04

strategy:
matrix:
toxiproxy:
- "2.6.0"
- "2.5.0"
- "2.1.2"
elixir:
- "1.15"
otp:
- "26.1"
include:
# Oldest supported version pair.
- otp: "23.3"
elixir: "1.10.4-otp-23"
toxiproxy: "2.1.2"

env:
TOXIPROXY_VERSION: ${{ matrix.toxiproxy }}

steps:
- uses: actions/checkout@v2
- uses: erlef/setup-beam@v1
- name: Check out this repository
uses: actions/checkout@v4

- name: Install Erlang and Elixir
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
version-type: strict
- run: curl --silent -L https://github.com/Shopify/toxiproxy/releases/download/v2.1.2/toxiproxy-server-linux-amd64 -o ./toxiproxy-server
- run: chmod +x ./toxiproxy-server
- run: nohup bash -c "./toxiproxy-server > ./toxiproxy.log 2>&1 &"
- run: mix deps.get
- run: mix test

- name: Install Toxiproxy
run: |
curl -v -L --fail https://github.com/Shopify/toxiproxy/releases/download/v${TOXIPROXY_VERSION}/toxiproxy-server-linux-amd64 -o ./toxiproxy-server
chmod +x ./toxiproxy-server

- name: Start Toxiproxy
run: nohup bash -c "./toxiproxy-server > ./toxiproxy.log 2>&1 &"

- name: Cache Mix compiled stuff
uses: actions/cache@v3
id: cache-mix
with:
path: |
_build
deps
key: |
mix-elixir${{ matrix.elixir }}-otp${{ matrix.otp }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
mix-elixir${{ matrix.elixir }}-otp${{ matrix.otp }}-${{ hashFiles('mix.lock') }}-${{ github.run_id }}-
mix-elixir${{ matrix.elixir }}-otp${{ matrix.otp }}-${{ hashFiles('mix.lock') }}-

- name: Install dependencies
run: mix deps.get

- name: Run tests
run: mix test

- name: Dump Toxiproxy logs on failure
if: failure()
run: cat ./toxiproxy.log
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ erl_crash.dump
# Ignore package tarball (built via "mix hex.build").
toxiproxy_ex-*.tar

# Dialyzer PLTs.
/plts
4 changes: 2 additions & 2 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
erlang 23.2
elixir 1.11.3-otp-23
erlang 26.0.2
elixir 1.15.4-otp-26
Comment on lines +1 to +2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modernized this

Jcambass marked this conversation as resolved.
Show resolved Hide resolved
Loading