forked from exercism/elixir
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Github Actions Support (exercism#545)
* Adding Github Actions support * Removing previous CI files * Add dependency caching (dialyzer)
- Loading branch information
Showing
15 changed files
with
359 additions
and
96 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Maintainers | ||
# Maintainers | ||
config/maintainers.json @exercism/maintainers-admin | ||
|
||
# Code owners | ||
|
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,105 @@ | ||
# This workflow will do a clean install of the dependencies and run tests across different versions | ||
# | ||
# Requires scripts: | ||
# - bin/ci.sh | ||
# - bin/ci-check.sh | ||
|
||
name: elixir / main ci | ||
|
||
on: | ||
push: | ||
branches: [master, main] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
precheck: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Elixir | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: '22.2' | ||
elixir-version: '1.10.0' | ||
|
||
- name: Retrieve Mix Dependencies Cache | ||
uses: actions/cache@v1 | ||
id: mix-cache # id to use in retrieve action | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
|
||
- name: Install Mix Dependencies | ||
if: steps.mix-cache.outputs.cache-hit != 'true' | ||
run: | | ||
mix local.rebar --force | ||
mix local.hex --force | ||
mix deps.get | ||
- name: Build Project | ||
run: mix | ||
|
||
- name: Retrieve PLT Cache | ||
uses: actions/cache@v1 | ||
id: plt-cache | ||
with: | ||
path: priv/plts | ||
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-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 --plt | ||
- name: Run Prechecks | ||
run: bin/ci-check.sh | ||
|
||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
#Note: pick a canonical set of supported versions | ||
elixir: ['1.6.0', '1.7.0'] | ||
otp: ['19.0'] | ||
include: | ||
- elixir: '1.8.0' | ||
otp: '20.0' | ||
- elixir: '1.9.0' | ||
otp: '20.0' | ||
- elixir: '1.10.0' | ||
otp: '21.0' | ||
- elixir: '1.10.0' | ||
otp: '22.2' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Elixir ${{matrix.elixir}} / OTP ${{matrix.otp}} | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{matrix.otp}} | ||
elixir-version: ${{matrix.elixir}} | ||
|
||
- name: Retrieve Mix Dependencies Cache | ||
uses: actions/cache@v1 | ||
id: mix-cache # id to use in retrieve action | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
|
||
- name: Install Mix Dependencies | ||
if: steps.mix-cache.outputs.cache-hit != 'true' | ||
run: | | ||
mix local.rebar --force | ||
mix local.hex --force | ||
mix deps.get | ||
- name: Build Project | ||
run: mix | ||
|
||
- name: Run Checks | ||
run: bin/ci.sh |
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,18 @@ | ||
# This workflow will do a fetch the latest configlet binary and lint this repository. | ||
|
||
name: configlet | ||
|
||
on: [push, pull_request, workflow_dispatch] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Fetch configlet | ||
uses: exercism/github-actions/configlet-ci@master | ||
|
||
- name: Configlet Linter | ||
run: configlet lint . |
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,111 @@ | ||
# This workflow will do a clean install of the dependencies and run tests across different versions | ||
# | ||
# Requires scripts: | ||
# - bin/pr-check.sh | ||
# - bin/pr.sh | ||
|
||
name: elixir / pr | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
precheck: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout PR | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Elixir | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: '22.2' | ||
elixir-version: '1.10.0' | ||
|
||
- name: Retrieve Mix Dependencies Cache | ||
uses: actions/cache@v1 | ||
id: mix-cache # id to use in retrieve action | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
|
||
- name: Install Mix Dependencies | ||
if: steps.mix-cache.outputs.cache-hit != 'true' | ||
run: | | ||
mix local.rebar --force | ||
mix local.hex --force | ||
mix deps.get | ||
- name: Build Project | ||
run: mix | ||
|
||
- name: Retrieve PLT Cache | ||
uses: actions/cache@v1 | ||
id: plt-cache | ||
with: | ||
path: priv/plts | ||
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-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 --plt | ||
# Replace <code-extensions> with file extensions that should trigger this check. Replace with .* to allow anything. | ||
- name: Run exercism/elixir ci pre-check (stub files, config integrity) for changed exercises | ||
run: | | ||
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH") | ||
curl --url $"${PULL_REQUEST_URL}/files" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \ | ||
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(ex|exs|md|json)$")) | .filename' | \ | ||
xargs -r bin/pr-check.sh | ||
ci: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
elixir: ['1.6.0', '1.7.0'] | ||
otp: ['19.0'] | ||
include: | ||
- elixir: '1.8.0' | ||
otp: '20.0' | ||
- elixir: '1.9.0' | ||
otp: '20.0' | ||
- elixir: '1.10.0' | ||
otp: '21.0' | ||
- elixir: '1.10.0' | ||
otp: '22.2' | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Use Elixir ${{matrix.elixir}} / OTP ${{matrix.otp}} | ||
uses: actions/setup-elixir@v1 | ||
with: | ||
otp-version: ${{matrix.otp}} | ||
elixir-version: ${{matrix.elixir}} | ||
|
||
- name: Retrieve Mix Dependencies Cache | ||
uses: actions/cache@v1 | ||
id: mix-cache # id to use in retrieve action | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-${{ matrix.otp }}-${{ matrix.elixir }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | ||
|
||
- name: Install Mix Dependencies | ||
if: steps.mix-cache.outputs.cache-hit != 'true' | ||
run: | | ||
mix local.rebar --force | ||
mix local.hex --force | ||
mix deps.get | ||
- name: Build Project | ||
run: mix | ||
|
||
# Replace <code-extensions> with file extensions that should trigger running tests. Replace with .* to allow anything. | ||
- name: Run exercism/elixir ci (runs tests) for changed/added exercises | ||
run: | | ||
PULL_REQUEST_URL=$(jq -r ".pull_request.url" "$GITHUB_EVENT_PATH") | ||
curl --url $"${PULL_REQUEST_URL}/files" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | \ | ||
jq -c '.[] | select(.status == "added" or .status == "modified") | select(.filename | match("\\.(ex|exs|md|json)$")) | .filename' | \ | ||
xargs -r bin/pr.sh |
This file was deleted.
Oops, something went wrong.
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,26 @@ | ||
#!/bin/bash | ||
|
||
# ### | ||
# check_formatting.sh | ||
# ### | ||
# Uses `mix format` to validate formatting of all elixir code | ||
# Looks for trailing whitespace in files | ||
# ### | ||
echo "Running 'mix format'" | ||
mix format --check-formatted | ||
FORMAT_EXIT_CODE="$?" | ||
|
||
echo "Checking for trailing whitespace" | ||
# git grep returns a 0 status if there is a match | ||
# so we negate the result for consistency | ||
! git grep --line-number ' $' | ||
GREP_EXIT_CODE="$?" | ||
|
||
if [ "$FORMAT_EXIT_CODE" -ne 0 -o "$GREP_EXIT_CODE" -ne 0 ] | ||
then | ||
echo "Formatting checks failed" | ||
exit 1; | ||
fi | ||
|
||
echo "Formatting checks passed" | ||
exit 0; |
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,24 @@ | ||
#!/bin/bash | ||
|
||
# ### | ||
# ci-check.sh | ||
# ### | ||
# Precheck actions to run on a commit to master | ||
# ### | ||
|
||
echo "Running check_formatting.sh" | ||
("bin/check_formatting.sh") | ||
CHECK_FORMAT_EXIT_CODE="$?" | ||
|
||
echo "Running dialyzer_check.sh" | ||
("bin/dialyzer_check.sh") | ||
DIALYZER_EXIT_CODE="$?" | ||
|
||
if [ "$CHECK_FORMAT_EXIT_CODE" -ne 0 -o "$DIALYZER_EXIT_CODE" -ne 0 ] | ||
then | ||
echo "Precheck failed" | ||
exit 1; | ||
fi | ||
|
||
echo "Precheck passed" | ||
exit 0; |
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,20 @@ | ||
#!/bin/bash | ||
|
||
# ### | ||
# ci.sh | ||
# ### | ||
# Actions to run on a commit to master | ||
# ### | ||
|
||
echo "Running test_exercises.sh" | ||
("bin/test_exercises.sh") | ||
TEST_EXIT_CODE="$?" | ||
|
||
if [ "$TEST_EXIT_CODE" -ne 0 ] | ||
then | ||
echo "Tests failed" | ||
exit 1; | ||
fi | ||
|
||
echo "Tests passed" | ||
exit 0; |
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
Oops, something went wrong.