Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagoesteves committed May 17, 2024
0 parents commit 1fdaa43
Show file tree
Hide file tree
Showing 62 changed files with 3,699 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[
import_deps: [:phoenix],
plugins: [Phoenix.LiveView.HTMLFormatter],
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}"]
]
123 changes: 123 additions & 0 deletions .github/workflows/pr-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Calori Website CI

on:
pull_request:
branches: [main]

env:
MIX_ENV: test

jobs:
setup:
name: Setup
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Setup BEAM
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict

- name: Cache
uses: actions/cache@v3
with:
path: |
_build
deps
key: |
calori-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }}-2024-05-10
restore-keys: |
calori-
- name: Install Elixir dependencies
run: mix do deps.get, compile --warnings-as-errors

test:
name: Test
needs: setup
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup BEAM
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict

- name: Cache
uses: actions/cache@v3
with:
path: |
_build
deps
key: |
calori-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }}-2024-05-10
restore-keys: |
calori-
- name: Run tests
run: mix test

analysis:
name: Static Analysis
needs: setup
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup BEAM
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict

- name: Cache
uses: actions/cache@v3
with:
path: |
_build
deps
apps/site_web/assets/node_modules
key: |
calori-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }}-${{ hashFiles('apps/site_web/assets/yarn.lock') }}-2024-05-10
restore-keys: |
calori-
- name: Install Elixir dependencies
run: mix do deps.get, compile --warnings-as-errors

- name: Credo
run: mix credo --strict

- name: Mix Audit
run: mix deps.audit

- name: Mix Sobelow
run: mix sobelow --exit --threshold medium --skip -i Config.HTTPS

- name: Formatted
run: mix format --check-formatted

- name: Restore PLT cache
uses: actions/cache@v3
id: plt_cache
with:
key: plt-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('**/*.ex') }}
restore-keys: |
plt-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('**/*.ex') }}
plt-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-${{ hashFiles('**/mix.lock') }}-
plt-${{ steps.beam.outputs.otp-version }}-${{ steps.beam.outputs.elixir-version }}-
plt-${{ steps.beam.outputs.otp-version }}-
path: priv/plts

- name: Create PLTs
if: steps.plt_cache.outputs.cache-hit != 'true' || github.run_attempt != '1'
run: mix dialyzer --plt

- name: Run Dialyzer
run: mix dialyzer --format github
66 changes: 66 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Publish a release file/version to AWS

on:
push:
branches:
- main

env:
MIX_ENV: prod

jobs:
build:
name: Building Calori release and publishing it at AWS
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Setup BEAM
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict

- name: Capture GITHUB_SHORT_SHA
run: |
GITHUB_SHORT_SHA=$(git rev-parse --short ${{ github.sha }})
echo "GITHUB_SHORT_SHA=${GITHUB_SHORT_SHA}" >> $GITHUB_ENV
- name: Capture and update project mix version
run: |
MIX_VERSION=`grep "version:" mix.exs | awk -F'"' '{print $2}'`
CALORI_VERSION=${MIX_VERSION}-${GITHUB_SHORT_SHA}
echo "CALORI_VERSION=${CALORI_VERSION}" >> $GITHUB_ENV
sed -i "s/.*version:.*/ version: \"${CALORI_VERSION}\",/" mix.exs
- name: Create Release file version
run: |
echo "{\"version\":\"${CALORI_VERSION}\",\"hash\":\"${GITHUB_SHA}\"}" | jq > current.json
- name: Install Elixir dependencies
run: mix do deps.get, compile

- name: Assets Deploy
run: mix assets.deploy

- name: Generate a Release
run: mix release

- name: Copy a release file to the s3 distribution folder
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: "sa-east-1"
source: '_build/prod/*.tar.gz'
dest: 's3://${{ secrets.S3_DIST_URL }}/dist/calori/calori-${CALORI_VERSION}.tar.gz'

- name: Copy a version file to the s3 version folder
uses: prewk/s3-cp-action@v2
with:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_region: "sa-east-1"
source: 'current.json'
dest: 's3://${{ secrets.S3_DIST_URL }}/versions/calori/prod/current.json'
51 changes: 51 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where 3rd-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Temporary files, for example, from tests.
/tmp/

# Ignore package tarball (built via "mix hex.build").
calori-*.tar

# Ignore assets that are produced by build tools.
/priv/static/assets/

# Ignore digested assets cache.
/priv/static/cache_manifest.json

# In case you use Node.js/npm, you want to ignore these.
npm-debug.log
/assets/node_modules/

# Certificates and public/private keys
*.crt
*.key
*.p8
*.pub

# Ignore .env files
*.env

*.DS_Store

config/*.secret.exs

.container
3 changes: 3 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
erlang 26.1.2
elixir 1.16.0-otp-26
terraform 1.5.6
Loading

0 comments on commit 1fdaa43

Please sign in to comment.