Skip to content

Commit

Permalink
chore: split Elixir tasks (#375)
Browse files Browse the repository at this point in the history
Split CI tasks related to Elixir to improve build times by parallelizing
different steps.
  • Loading branch information
hauleth authored Jun 28, 2024
1 parent 48dac52 commit 9f56b87
Show file tree
Hide file tree
Showing 8 changed files with 259 additions and 79 deletions.
3 changes: 3 additions & 0 deletions .dialyzer_ignore.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
~r(test/support/[^.]*\.ex)
]
234 changes: 234 additions & 0 deletions .github/workflows/elixir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
name: Elixir tests
on:
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
SECRET_KEY_BASE: ${{ secrets.SECRET_KEY_BASE }}
LANG: C.UTF-8
LC_ALL: C.UTF-8
MIX_ENV: test

jobs:
deps:
name: Fetch deps
runs-on: u22-arm-runner

steps:
- uses: actions/checkout@v4
- name: Setup Elixir
id: beam
uses: erlef/setup-beam@v1
with:
otp-version: '25.3.2.7'
elixir-version: '1.14.5'
- name: Cache Mix
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
- name: Install dependencies
run: mix deps.get

compile:
name: Compile project in test env
runs-on: u22-arm-runner
needs: [deps]

steps:
- uses: actions/checkout@v4
- name: Setup Elixir
id: beam
uses: erlef/setup-beam@v1
with:
otp-version: '25.3.2.7'
elixir-version: '1.14.5'
- name: Cache Mix
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
- name: Cache Build
uses: actions/cache@v4
with:
path: |
_build/${{ env.MIX_ENV }}
key: ${{ runner.os }}-build-${{ env.MIX_ENV }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ env.MIX_ENV }}-
- name: Cache native
uses: actions/cache@v4
id: native-cache
with:
path: |
priv/native
key: ${{ runner.os }}-build-native-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles(format('{0}{1}', github.workspace, '/native/**/*')) }}
- name: Set up Rust
uses: dtolnay/rust-toolchain@v1
if: steps.native-cache.outputs.cache-hit != 'true' || steps.elixir-cache.output.cache-hit != 'true'
with:
toolchain: stable
- name: Compile
run: mix compile

format:
name: Formatting checks
runs-on: u22-arm-runner
needs: [deps]

steps:
- uses: actions/checkout@v4
- name: Setup Elixir
id: beam
uses: erlef/setup-beam@v1
with:
otp-version: '25.3.2.7'
elixir-version: '1.17'
- name: Cache Mix
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
- name: Run format check
run: mix format --check-formatted

credo:
name: Code style
runs-on: u22-arm-runner
needs: [compile]

steps:
- uses: actions/checkout@v4
- name: Setup Elixir
id: beam
uses: erlef/setup-beam@v1
with:
otp-version: '25.3.2.7'
elixir-version: '1.14.5'
- name: Cache Mix
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
- name: Cache Build
uses: actions/cache@v4
with:
path: |
_build/${{ env.MIX_ENV }}
key: ${{ runner.os }}-build-${{ env.MIX_ENV }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ env.MIX_ENV }}-
- name: Credo checks
run: mix credo --strict --mute-exit-status

tests:
name: Run tests
runs-on: u22-arm-runner
needs: [compile]

steps:
- uses: actions/checkout@v4
- name: Setup Elixir
id: beam
uses: erlef/setup-beam@v1
with:
otp-version: '25.3.2.7'
elixir-version: '1.14.5'
- name: Set up Rust
uses: dtolnay/rust-toolchain@v1
if: steps.native-cache.outputs.cache-hit != 'true' || steps.elixir-cache.output.cache-hit != 'true'
with:
toolchain: stable
- name: Cache Mix
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
- name: Cache Build
uses: actions/cache@v4
with:
path: |
_build/${{ env.MIX_ENV }}
key: ${{ runner.os }}-build-${{ env.MIX_ENV }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ env.MIX_ENV }}-
- name: Cache native
uses: actions/cache@v4
with:
path: |
priv/native
key: ${{ runner.os }}-build-native-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles(format('{0}{1}', github.workspace, '/native/**/*')) }}
- name: Set up Postgres
run: docker-compose -f ./docker-compose.db.yml up -d
- name: Start epmd
run: epmd -daemon
- name: Run tests
run: mix test

dialyzer:
name: Dialyze
runs-on: u22-arm-runner
needs: [compile]

steps:
- uses: actions/checkout@v4
- name: Setup Elixir
id: beam
uses: erlef/setup-beam@v1
with:
otp-version: '25.3.2.7'
elixir-version: '1.14.5'
- name: Set up Rust
uses: dtolnay/rust-toolchain@v1
if: steps.native-cache.outputs.cache-hit != 'true' || steps.elixir-cache.output.cache-hit != 'true'
with:
toolchain: stable
- name: Cache Mix
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
restore-keys: |
${{ runner.os }}-mix-
- name: Cache Build
uses: actions/cache@v4
with:
path: |
_build/${{ env.MIX_ENV }}
key: ${{ runner.os }}-build-${{ env.MIX_ENV }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-build-${{ env.MIX_ENV }}-
- name: Cache native
uses: actions/cache@v4
with:
path: |
priv/native
key: ${{ runner.os }}-build-native-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles(format('{0}{1}', github.workspace, '/native/**/*')) }}
- name: Retrieve PLT Cache
uses: actions/cache@v4
id: plt-cache
with:
path: _build/${{ env.MIX_ENV }}/*.plt
key: ${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-plts-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}
- name: Create PLTs
if: steps.plt-cache.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix dialyzer.build
- name: Run dialyzer
run: mix dialyzer
10 changes: 5 additions & 5 deletions .github/workflows/prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
permissions:
contents: write
packages: write
id-token: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set upgrade variables
run: |
elixir ./deploy/upgrade/handler.exs all_keys ./deploy/upgrade/prod.config
elixir ./deploy/upgrade/handler.exs all_keys ./deploy/upgrade/prod.config
echo "RELEASE_FROM=$(elixir ./deploy/upgrade/handler.exs upgrade_from ./deploy/upgrade/prod.config)" >> $GITHUB_ENV
echo "RELEASE_TO=$(elixir ./deploy/upgrade/handler.exs upgrade_to ./deploy/upgrade/prod.config)" >> $GITHUB_ENV
echo "NAME=$(elixir ./deploy/upgrade/handler.exs name ./deploy/upgrade/prod.config)" >> $GITHUB_ENV
Expand All @@ -33,9 +33,9 @@ jobs:
- name: Set up Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
toolchain: stable
- name: Get git tags
run: git fetch --tags origin
run: git fetch --tags origin
- name: Checkout RELEASE_FROM
run: git checkout v${{ env.RELEASE_FROM }}
- name: Cache Mix
Expand All @@ -51,7 +51,7 @@ jobs:
mix local.rebar --force
mix deps.get
- name: Make old release
run: mix release supavisor
run: mix release supavisor
- name: Checkout RELEASE_TO
run: git checkout v${{ env.RELEASE_TO }}
- name: Cache Mix
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
permissions:
contents: write
packages: write
id-token: write
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set upgrade variables
run: |
elixir ./deploy/upgrade/handler.exs all_keys ./deploy/upgrade/staging.config
elixir ./deploy/upgrade/handler.exs all_keys ./deploy/upgrade/staging.config
echo "RELEASE_FROM=$(elixir ./deploy/upgrade/handler.exs upgrade_from ./deploy/upgrade/staging.config)" >> $GITHUB_ENV
echo "RELEASE_TO=$(elixir ./deploy/upgrade/handler.exs upgrade_to ./deploy/upgrade/staging.config)" >> $GITHUB_ENV
echo "NAME=$(elixir ./deploy/upgrade/handler.exs name ./deploy/upgrade/staging.config)" >> $GITHUB_ENV
Expand All @@ -33,9 +33,9 @@ jobs:
- name: Set up Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
toolchain: stable
- name: Get git tags
run: git fetch --tags origin
run: git fetch --tags origin
- name: Checkout RELEASE_FROM
run: git checkout v${{ env.RELEASE_FROM }}
- name: Cache Mix
Expand All @@ -51,7 +51,7 @@ jobs:
mix local.rebar --force
mix deps.get
- name: Make old release
run: mix release supavisor
run: mix release supavisor
- name: Checkout RELEASE_TO
run: git checkout v${{ env.RELEASE_TO }}
- name: Cache Mix
Expand Down
61 changes: 0 additions & 61 deletions .github/workflows/staging_linter.yml

This file was deleted.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.66
1.1.67
Loading

0 comments on commit 9f56b87

Please sign in to comment.