-
Notifications
You must be signed in to change notification settings - Fork 3
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
CI/CD with GHA #178
Merged
Merged
CI/CD with GHA #178
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d59bf00
gha_ci_cd
prima-backstage[bot] 0e61a5c
add ci/cd
cpiemontese aa4a347
change elixir version
cpiemontese 4237146
add redis service
cpiemontese e18a0c0
specify redis minor
cpiemontese 469b037
add env vars
cpiemontese 7bffdd5
add redis options
cpiemontese f58c9ff
update redis image
cpiemontese 3bb636a
add ports again
cpiemontese 1432fc0
try using a container
cpiemontese 7046774
add hex command
cpiemontese aef2c6e
rebar
cpiemontese d0180fa
update files
cpiemontese 61cf87d
align otp versions
cpiemontese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,39 @@ | ||
name: CD | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Elixir | ||
uses: erlef/setup-beam@v1 | ||
with: | ||
otp-version: '24' | ||
elixir-version: '1.13' | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: setup hex | ||
run: | | ||
mix mix local.hex --force | ||
mix local.rebar --force | ||
- name: Get deps | ||
run: mix deps.get | ||
- name: Get version | ||
run: | | ||
VERSION=$(grep -m1 version mix.exs | cut -d'"' -f2) | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Check version | ||
if: github.ref_tag != ${{ env.VERSION }} | ||
run: | | ||
echo "Github ref tag [${{ github.ref_tag }}] is different from mix.exs version [${{ env.VERSION }}]" | ||
exit 1 | ||
- name: Login to hex.pm | ||
run: | | ||
mix hex.config api_key "$HEX_AUTH_KEY" | ||
env: | ||
HEX_AUTH_KEY: ${{ secrets.HEX_AUTH_KEY }} | ||
- name: Publish | ||
run: mix hex.publish --yes |
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,97 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: elixir:1.13 | ||
env: | ||
MIX_ENV: test | ||
steps: | ||
# Check out the code. | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
# Define how to cache deps. Restores existing cache if present. | ||
- name: Cache deps | ||
id: cache-deps | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-elixir-deps | ||
with: | ||
path: deps | ||
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-mix-${{ env.cache-name }}- | ||
# Define how to cache the `_build` directory. | ||
# After the first run, this speeds up tests runs a lot. | ||
# This includes not re-compiling our project's downloaded deps every run. | ||
- name: Cache compiled build | ||
id: cache-build | ||
uses: actions/cache@v3 | ||
env: | ||
cache-name: cache-compiled-build | ||
with: | ||
path: _build | ||
key: ${{ runner.os }}-mix-${{ env.cache-name }}-${{ hashFiles('**/mix.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-mix-${{ env.cache-name }}- | ||
${{ runner.os }}-mix- | ||
# Conditionally bust the cache when job is re-run. | ||
# Sometimes, we may have issues with incremental builds that are fixed by doing a full recompile. | ||
# In order to not waste dev time on such trivial issues force a full recompile only on builds that are retried. | ||
# See https://fly.io/docs/elixir/advanced-guides/github-actions-elixir-ci-cd/ for more infos | ||
- name: Clean to rule out incremental build as a source of flakiness | ||
if: github.run_attempt != '1' | ||
run: | | ||
mix deps.clean --all | ||
mix clean | ||
- name: Elixir setup | ||
run: | | ||
mix local.hex --force | ||
mix local.rebar --force | ||
- name: Deps get | ||
run: mix deps.get | ||
- name: Dependencies Check | ||
run: mix deps.unlock --check-unused | ||
- name: Compiles without warnings | ||
run: mix compile --warnings-as-errors | ||
- name: Check Formatting | ||
run: mix format --check-formatted | ||
- name: Credo | ||
run: mix credo -a --strict | ||
- name: Test | ||
run: mix test | ||
- name: Dialyzer | ||
run: mix dialyzer | ||
|
||
services: | ||
redis: | ||
image: public.ecr.aws/bitnami/redis:5.0 | ||
env: | ||
ALLOW_EMPTY_PASSWORD: true | ||
options: >- | ||
--health-cmd "redis-cli ping" | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 6379:6379 | ||
|
||
alls-green: | ||
if: always() | ||
needs: | ||
- ci | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Decide whether the needed jobs succeeded or failed | ||
uses: re-actors/alls-green@release/v1 | ||
with: | ||
jobs: ${{ toJSON(needs) }} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has an ops person added this key for us already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The key is present and should be ok