Add Livebook integration for interactive learning #6
Workflow file for this run
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| pull_request: | |
| branches: [ master, main ] | |
| env: | |
| MIX_ENV: test | |
| ELIXIR_VERSION: '1.17' | |
| OTP_VERSION: '27.1' | |
| jobs: | |
| test: | |
| name: Test (Elixir ${{ matrix.elixir }} / OTP ${{ matrix.otp }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| elixir: ['1.17'] | |
| otp: ['27.1'] | |
| services: | |
| postgres: | |
| image: postgres:16 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: elixir_systems_test | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| ports: | |
| - 5432:5432 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: ${{ matrix.elixir }} | |
| otp-version: ${{ matrix.otp }} | |
| - name: Restore dependencies cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps | |
| _build | |
| key: ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}-${{ hashFiles('**/mix.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-${{ matrix.otp }}-${{ matrix.elixir }}- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Compile dependencies | |
| run: mix deps.compile | |
| - name: Compile code (warnings as errors) | |
| run: mix compile --warnings-as-errors | |
| - name: Check formatting | |
| run: mix format --check-formatted | |
| - name: Run tests with coverage | |
| run: | | |
| mix coveralls.json --umbrella --warnings-as-errors | tee coverage_output.txt | |
| # Extract coverage from output like "[TOTAL] 100.0%" | |
| COVERAGE=$(grep "\[TOTAL\]" coverage_output.txt | awk '{print $2}' | tr -d '%' | cut -d'.' -f1) | |
| echo "Coverage: ${COVERAGE}%" | |
| if [ ${COVERAGE} -lt 80 ]; then | |
| echo "❌ Coverage ${COVERAGE}% is below 80% threshold" | |
| exit 1 | |
| fi | |
| echo "✓ Coverage ${COVERAGE}% meets 80% threshold" | |
| env: | |
| MIX_ENV: test | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| files: ./cover/excoveralls.json | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: false | |
| - name: Run Credo | |
| run: mix credo --strict | |
| dialyzer: | |
| name: Dialyzer | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: ${{ env.ELIXIR_VERSION }} | |
| otp-version: ${{ env.OTP_VERSION }} | |
| - name: Restore PLT cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: priv/plts | |
| key: ${{ runner.os }}-plt-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-plt-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Run Dialyzer | |
| run: mix dialyzer | |
| security: | |
| name: Security Scans | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: ${{ env.ELIXIR_VERSION }} | |
| otp-version: ${{ env.OTP_VERSION }} | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Run Sobelow | |
| run: mix sobelow --exit | |
| - name: Run dependency audit | |
| run: mix deps.audit | |
| release: | |
| name: Build Release | |
| runs-on: ubuntu-latest | |
| needs: [test, dialyzer, security] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Elixir | |
| uses: erlef/setup-beam@v1 | |
| with: | |
| elixir-version: ${{ env.ELIXIR_VERSION }} | |
| otp-version: ${{ env.OTP_VERSION }} | |
| - name: Install dependencies | |
| run: mix deps.get --only prod | |
| env: | |
| MIX_ENV: prod | |
| - name: Compile for production | |
| run: mix compile | |
| env: | |
| MIX_ENV: prod | |
| - name: Build release | |
| run: mix release | |
| env: | |
| MIX_ENV: prod | |
| - name: Upload release artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: elixir-systems-mastery-release | |
| path: _build/prod/rel/ | |
| retention-days: 30 | |
| if-no-files-found: error | |
| - name: Create release archive | |
| run: | | |
| cd _build/prod | |
| tar -czf ../../elixir-systems-mastery.tar.gz rel/ | |
| cd ../.. | |
| - name: Upload release archive | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: elixir-systems-mastery-archive | |
| path: elixir-systems-mastery.tar.gz | |
| retention-days: 30 |