-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from s3cur3/main
Support building on Mac, and add CI runners to test builds
- Loading branch information
Showing
7 changed files
with
211 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: Setup Elixir Project | ||
description: Checks out the code, configures Elixir, fetches dependencies, and manages build caching. | ||
inputs: | ||
elixir-version: | ||
required: true | ||
type: string | ||
description: Elixir version to set up | ||
otp-version: | ||
required: true | ||
type: string | ||
description: OTP version to set up | ||
################################################################# | ||
# Everything below this line is optional. | ||
# | ||
# It's designed to make compiling a reasonably standard Elixir | ||
# codebase "just work," though there may be speed gains to be had | ||
# by tweaking these flags. | ||
################################################################# | ||
build-deps: | ||
required: false | ||
type: boolean | ||
default: true | ||
description: True if we should compile dependencies | ||
build-app: | ||
required: false | ||
type: boolean | ||
default: true | ||
description: True if we should compile the application itself | ||
build-flags: | ||
required: false | ||
type: string | ||
default: '--all-warnings' | ||
description: Flags to pass to mix compile | ||
install-rebar: | ||
required: false | ||
type: boolean | ||
default: true | ||
description: By default, we will install Rebar (mix local.rebar --force). | ||
install-hex: | ||
required: false | ||
type: boolean | ||
default: true | ||
description: By default, we will install Hex (mix local.hex --force). | ||
cache-key: | ||
required: false | ||
type: string | ||
default: 'v1' | ||
description: If you need to reset the cache for some reason, you can change this key. | ||
outputs: | ||
otp-version: | ||
description: "Exact OTP version selected by the BEAM setup step" | ||
value: ${{ steps.beam.outputs.otp-version }} | ||
elixir-version: | ||
description: "Exact Elixir version selected by the BEAM setup step" | ||
value: ${{ steps.beam.outputs.elixir-version }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup elixir | ||
uses: erlef/setup-beam@v1 | ||
id: beam | ||
with: | ||
elixir-version: ${{ inputs.elixir-version }} | ||
otp-version: ${{ inputs.otp-version }} | ||
|
||
- name: Get deps cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: deps/ | ||
key: deps-${{ inputs.cache-key }}-${{ runner.os }}-${{ hashFiles('**/mix.lock') }} | ||
restore-keys: | | ||
deps-${{ inputs.cache-key }}-${{ runner.os }}- | ||
- name: Get build cache | ||
uses: actions/cache@v2 | ||
id: build-cache | ||
with: | ||
path: _build/${{env.MIX_ENV}}/ | ||
key: build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}-${{ hashFiles('**/mix.lock') }} | ||
restore-keys: | | ||
build-${{ inputs.cache-key }}-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ env.MIX_ENV }}- | ||
- name: Get Hex cache | ||
uses: actions/cache@v2 | ||
id: hex-cache | ||
with: | ||
path: ~/.hex | ||
key: build-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}-${{ hashFiles('**/mix.lock') }} | ||
restore-keys: | | ||
build-${{ runner.os }}-${{ inputs.otp-version }}-${{ inputs.elixir-version }}- | ||
# In my experience, I have issues with incremental builds maybe 1 in 100 | ||
# times that are fixed by doing a full recompile. | ||
# In order to not waste dev time on such trivial issues (while also reaping | ||
# the time savings of incremental builds for *most* day-to-day development), | ||
# I force a full recompile only on builds that we retry. | ||
- name: Clean to rule out incremental build as a source of flakiness | ||
if: github.run_attempt != '1' | ||
run: | | ||
mix deps.clean --all | ||
mix clean | ||
shell: sh | ||
|
||
- name: Install Rebar | ||
run: mix local.rebar --force | ||
shell: sh | ||
if: inputs.install-rebar == 'true' | ||
|
||
- name: Install Hex | ||
run: mix local.hex --force | ||
shell: sh | ||
if: inputs.install-hex == 'true' | ||
|
||
- name: Install Dependencies | ||
run: mix deps.get | ||
shell: sh | ||
|
||
# Normally we'd use `mix deps.compile` here, however that incurs a large | ||
# performance penalty when the dependencies are already fully compiled: | ||
# https://elixirforum.com/t/github-action-cache-elixir-always-recompiles-dependencies-elixir-1-13-3/45994/12 | ||
# | ||
# Accoring to Jose Valim at the above link `mix loadpaths` will check and | ||
# compile missing dependencies | ||
- name: Compile Dependencies | ||
run: mix loadpaths | ||
shell: sh | ||
if: inputs.build-deps == 'true' | ||
|
||
- name: Compile Application | ||
run: mix compile ${{ inputs.build-flags }} | ||
shell: sh | ||
if: inputs.build-app == 'true' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: mix | ||
directory: "/" | ||
schedule: | ||
interval: daily | ||
time: "12:00" | ||
open-pull-requests-limit: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
build_linux: | ||
name: Build and test on Linux | ||
runs-on: ubuntu-22.04 | ||
env: | ||
MIX_ENV: test | ||
elixir: "1.15.7" | ||
otp: "26.1.2" | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Elixir Project | ||
uses: ./.github/actions/elixir-setup | ||
with: | ||
elixir-version: ${{ env.elixir }} | ||
otp-version: ${{ env.otp }} | ||
build-flags: --all-warnings --warnings-as-errors | ||
|
||
- name: Run Tests | ||
run: mix test --warnings-as-errors | ||
if: always() | ||
|
||
build_mac: | ||
name: Build and test on Mac | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Elixir Project | ||
run: brew install elixir | ||
|
||
- name: Get deps | ||
run: mix deps.get | ||
|
||
- name: Compile | ||
run: mix compile --all-warnings --warnings-as-errors | ||
|
||
- name: Run Tests | ||
run: mix test --warnings-as-errors | ||
if: always() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,4 @@ ex_brotli-*.tar | |
# Temporary files, for example, from tests. | ||
/tmp/ | ||
/priv/brotli_nif.so | ||
/priv/brotli_nif.so.dSYM/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
%{ | ||
"elixir_make": {:hex, :elixir_make, "0.6.2", "7dffacd77dec4c37b39af867cedaabb0b59f6a871f89722c25b28fcd4bd70530", [:mix], [], "hexpm", "03e49eadda22526a7e5279d53321d1cced6552f344ba4e03e619063de75348d9"}, | ||
"elixir_make": {:hex, :elixir_make, "0.7.7", "7128c60c2476019ed978210c245badf08b03dbec4f24d05790ef791da11aa17c", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}], "hexpm", "5bc19fff950fad52bbe5f211b12db9ec82c6b34a9647da0c2224b8b8464c7e6c"}, | ||
} |