Kamal #4814
Workflow file for this run
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
name: Elixir CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
ELIXIR_VERSION: "1.17.0" | |
ERLANG_VERSION: "27.0" | |
jobs: | |
build_dev: | |
name: mix compile and dialyzer | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dev config | |
run: cp config/dev.secret.example.exs config/dev.secret.exs | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
otp-version: ${{ env.ERLANG_VERSION }} | |
- name: Restore dev cache | |
uses: actions/cache@v4 | |
id: dev-cache | |
with: | |
path: | | |
deps | |
_build/dev | |
key: v1-dev-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
restore-keys: v1-dev- | |
- name: Restore PLT cache | |
uses: actions/cache@v4 | |
with: | |
path: _plts | |
key: v3-plts-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
restore-keys: | | |
v3-plts-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
v3-plts-${{ hashFiles('.tool-versions') }}- | |
- run: mix deps.get | |
if: steps.dev-cache.outputs.cache-hit != 'true' | |
- run: mix compile --warnings-as-errors | |
- run: mix format --check-formatted | |
- run: mix dialyzer | |
yarn_install: | |
name: yarn install and bundle | |
runs-on: ubuntu-latest | |
env: | |
MIX_ENV: prod | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Read .tool-versions | |
uses: marocchino/tool-versions-action@v1 | |
id: versions | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ steps.versions.outputs.nodejs }} | |
- name: Restore node_modules cache | |
uses: actions/cache@v4 | |
with: | |
path: apps/client/assets/node_modules | |
key: v3-node-modules-${{ hashFiles('.tool-versions') }}-${{ hashFiles('apps/client/assets/yarn.lock') }} | |
restore-keys: | | |
v3-node-modules-${{ hashFiles('.tool-versions') }}-${{ hashFiles('apps/client/assets/yarn.lock') }} | |
- name: Restore yarn cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/yarn | |
~/.cache/Cypress | |
key: v3-yarn-${{ hashFiles('.tool-versions') }}-${{ hashFiles('apps/client/assets/yarn.lock') }} | |
restore-keys: | | |
v3-yarn-${{ hashFiles('.tool-versions') }}-${{ hashFiles('apps/client/assets/yarn.lock') }} | |
- name: Restore static asset cache | |
uses: actions/cache@v4 | |
with: | |
path: apps/client/priv/static | |
key: v3-static-assets-${{ github.ref }}-${{ github.sha }} | |
restore-keys: | | |
v3-static-assets-${{ github.ref }}-${{ github.sha }} | |
v3-static-assets-${{ github.ref }}- | |
- name: yarn install | |
working-directory: apps/client/assets | |
run: yarn install --frozen-lockfile | |
- name: yarn lint --check | |
working-directory: apps/client/assets | |
run: yarn lint --check | |
- name: yarn typecheck | |
working-directory: apps/client/assets | |
run: yarn typecheck | |
- name: yarn bundle:js | |
working-directory: apps/client/assets | |
run: yarn bundle:js | |
- name: yarn bundle:css | |
working-directory: apps/client/assets | |
run: yarn bundle:css | |
playwright: | |
timeout-minutes: 60 | |
runs-on: ubuntu-latest | |
needs: ["yarn_install"] | |
env: | |
MIX_ENV: test | |
LOG_LEVEL: info | |
TWITCH_DATASTORE_DISABLED: "true" | |
POSTGRES_PASSWORD: password | |
services: | |
postgres: | |
image: postgres:15-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: homepage_test | |
POSTGRES_PASSWORD: password | |
ports: | |
- 5432:5432 | |
redis: | |
image: circleci/redis | |
ports: | |
- 6379:6379 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Read .tool-versions | |
uses: marocchino/tool-versions-action@v1 | |
id: versions | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ steps.versions.outputs.nodejs }} | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
otp-version: ${{ env.ERLANG_VERSION }} | |
- name: Restore test cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps | |
_build/test | |
key: v2-test-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
restore-keys: | | |
v2-test-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
v2-test-${{ hashFiles('.tool-versions') }}- | |
- name: Restore node_modules cache | |
uses: actions/cache@v4 | |
with: | |
path: apps/client/assets/node_modules | |
key: v3-node-modules-${{ hashFiles('.tool-versions') }}-${{ hashFiles('apps/client/assets/yarn.lock') }} | |
restore-keys: | | |
v3-node-modules-${{ hashFiles('.tool-versions') }}-${{ hashFiles('apps/client/assets/yarn.lock') }} | |
- name: Restore yarn cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/yarn | |
~/.cache/Cypress | |
key: v3-yarn-${{ hashFiles('.tool-versions') }}-${{ hashFiles('apps/client/assets/yarn.lock') }} | |
restore-keys: | | |
v3-yarn-${{ hashFiles('.tool-versions') }}-${{ hashFiles('apps/client/assets/yarn.lock') }} | |
- name: Restore static asset cache | |
uses: actions/cache@v4 | |
with: | |
path: apps/client/priv/static | |
key: v3-static-assets-${{ github.ref }}-${{ github.sha }} | |
restore-keys: | | |
v3-static-assets-${{ github.ref }}-${{ github.sha }} | |
v3-static-assets-${{ github.ref }}- | |
- run: mix deps.get | |
- run: mix do ecto.create, ecto.migrate | |
- run: MIX_ENV=test LOG_LEVEL=debug mix phx.server &> server.log & | |
- name: Install Playwright Browsers | |
run: yarn playwright install firefox --with-deps | |
working-directory: apps/client/assets | |
- name: Run Playwright tests | |
run: yarn playwright test | |
working-directory: apps/client/assets | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report | |
path: apps/client/assets/playwright-report/ | |
retention-days: 30 | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: server-logs | |
path: server.log | |
retention-days: 30 | |
cypress_run: | |
name: cypress run | |
needs: ["yarn_install"] | |
runs-on: ubuntu-latest | |
env: | |
MIX_ENV: test | |
LOG_LEVEL: info | |
TWITCH_DATASTORE_DISABLED: "true" | |
POSTGRES_PASSWORD: password | |
services: | |
postgres: | |
image: postgres:15-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: homepage_test | |
POSTGRES_PASSWORD: password | |
ports: | |
- 5432:5432 | |
redis: | |
image: circleci/redis | |
ports: | |
- 6379:6379 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dev config | |
run: cp config/dev.secret.example.exs config/dev.secret.exs | |
- name: Read .tool-versions | |
uses: marocchino/tool-versions-action@v1 | |
id: versions | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ steps.versions.outputs.nodejs }} | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
otp-version: ${{ env.ERLANG_VERSION }} | |
- name: Restore test cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps | |
_build/test | |
key: v2-test-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
restore-keys: | | |
v2-test-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
v2-test-${{ hashFiles('.tool-versions') }}- | |
- name: Restore static asset cache | |
uses: actions/cache@v4 | |
with: | |
path: apps/client/priv/static | |
key: v3-static-assets-${{ github.ref }}-${{ github.sha }} | |
restore-keys: | | |
v3-static-assets-${{ github.ref }}-${{ github.sha }} | |
v3-static-assets-${{ github.ref }}- | |
- run: mix deps.get | |
- run: mix do ecto.create, ecto.migrate | |
- run: MIX_ENV=test mix phx.server & | |
- name: Cypress run | |
uses: cypress-io/github-action@v6 | |
with: | |
working-directory: apps/client/assets | |
- name: Archive failure screenshots | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: cypress-failure-screenshots | |
path: apps/client/assets/cypress/screenshots | |
- name: Archive videos | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: videos | |
path: apps/client/assets/cypress/videos | |
mix_test: | |
name: mix test | |
needs: yarn_install | |
runs-on: ubuntu-latest | |
env: | |
MIX_ENV: test | |
TWITCH_DATASTORE_DISABLED: "true" | |
POSTGRES_PASSWORD: password | |
services: | |
postgres: | |
image: postgres:15-alpine | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_DB: homepage_test | |
POSTGRES_PASSWORD: password | |
ports: | |
- 5432:5432 | |
redis: | |
image: circleci/redis | |
ports: | |
- 6379:6379 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dev config | |
run: cp config/dev.secret.example.exs config/dev.secret.exs | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
otp-version: ${{ env.ERLANG_VERSION }} | |
- name: Restore static asset cache | |
uses: actions/cache@v4 | |
with: | |
path: apps/client/priv/static | |
key: v3-static-assets-${{ github.ref }}-${{ github.sha }} | |
- name: Restore test cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
deps | |
_build/test | |
key: v2-test-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
restore-keys: | | |
v2-test-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
v2-test-${{ hashFiles('.tool-versions') }}- | |
- run: mix deps.get | |
- run: mix compile --warnings-as-errors | |
- run: mix do ecto.create, ecto.migrate | |
- run: (mix test || true) && mix test --failed | |
- name: Archive failure screenshots | |
uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: mix-test-failure-screenshots | |
path: /tmp/homepage-screenshots | |
build_release: | |
if: github.ref == 'refs/heads/main' | |
name: build release | |
needs: | |
- build_dev | |
- yarn_install | |
runs-on: ubuntu-latest | |
env: | |
MIX_ENV: prod | |
TWITCH_DATASTORE_DISABLED: "true" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup dev config | |
run: cp config/dev.secret.example.exs config/dev.secret.exs | |
- name: Set up Elixir | |
uses: erlef/setup-beam@v1 | |
with: | |
elixir-version: ${{ env.ELIXIR_VERSION }} | |
otp-version: ${{ env.ERLANG_VERSION }} | |
- name: Restore static asset cache | |
uses: actions/cache@v4 | |
with: | |
path: apps/client/priv/static | |
key: v3-static-assets-${{ github.ref }}-${{ github.sha }} | |
- name: Restore dev cache | |
uses: actions/cache@v4 | |
id: dev-cache | |
with: | |
path: | | |
deps | |
_build/dev | |
key: v1-dev-${{ hashFiles('.tool-versions') }}-${{ hashFiles('mix.lock') }} | |
restore-keys: v1-dev- | |
- run: mix deps.get | |
- run: mix compile --warnings-as-errors | |
- run: mix phx.digest | |
- run: mix release homepage | |
- name: Archive release | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release | |
path: _build/prod/rel/homepage | |
deploy: | |
# if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
env: | |
KAMAL_REGISTRY_USERNAME: ${{ secrets.KAMAL_REGISTRY_USERNAME }} | |
KAMAL_REGISTRY_PASSWORD: ${{ secrets.KAMAL_REGISTRY_PASSWORD }} | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
concurrency: | |
group: deploy | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: SSH Auth | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_KEY }} | |
- run: "ssh-keyscan -H jutonz.com > ~/.ssh/known_hosts" | |
- name: Install Ruby | |
uses: ruby/setup-ruby@v1 | |
env: | |
BUNDLE_GEMFILE: .kamal/Gemfile | |
with: | |
ruby-version: 3.4 | |
bundler-cache: true | |
- run: tree vendor | |
- run: export PATH="$(pwd)/vendor/bundle/ruby/3.4.0/bin:$PATH" | |
- run: kamal deploy |