feat: add minimal workflow to test GitHub Actions #3
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: [main, develop] | |
| pull_request: | |
| branches: [main, develop] | |
| env: | |
| MIX_ENV: test | |
| jobs: | |
| # Simplified test job (no matrix) | |
| test: | |
| name: Test and Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install mise and tools | |
| uses: jdx/mise-action@v2 | |
| with: | |
| install: true | |
| cache: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps/ | |
| _build/ | |
| key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('mise.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}- | |
| ${{ runner.os }}-mix- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Check code formatting | |
| run: mix format --check-formatted | |
| - name: Check for unused dependencies | |
| run: mix deps.unlock --check-unused | |
| - name: Run Credo | |
| run: mix credo --strict | |
| - name: Compile application | |
| run: mix compile --warnings-as-errors | |
| - name: Run tests | |
| run: mix test --warnings-as-errors | |
| - name: Generate coverage report | |
| run: mix coveralls.github | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload coverage artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: cover/ | |
| # Pre-commit validation (parallel with test) | |
| pre-commit: | |
| name: Pre-commit Checks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install mise and tools | |
| uses: jdx/mise-action@v2 | |
| with: | |
| install: true | |
| cache: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps/ | |
| _build/ | |
| key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ hashFiles('lib/**/*.ex') }}-${{ hashFiles('test/**/*.exs') }}-${{ hashFiles('mise.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ hashFiles('lib/**/*.ex') }}-${{ hashFiles('test/**/*.exs') }}- | |
| ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}- | |
| ${{ runner.os }}-mix- | |
| - name: Install dependencies | |
| run: | | |
| mix local.hex --force | |
| mix deps.get | |
| - name: Run pre-commit | |
| uses: pre-commit/action@v3.0.1 | |
| # Documentation generation (depends on successful test) | |
| docs: | |
| name: Documentation | |
| runs-on: ubuntu-latest | |
| needs: test | |
| env: | |
| MIX_ENV: dev | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install mise and tools | |
| uses: jdx/mise-action@v2 | |
| with: | |
| install: true | |
| cache: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps/ | |
| _build/ | |
| key: ${{ runner.os }}-mix-dev-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ hashFiles('mise.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-dev-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}- | |
| ${{ runner.os }}-mix-dev- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Generate documentation | |
| run: mix docs | |
| - name: Upload documentation | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: documentation | |
| path: doc/ | |
| # Security audit (parallel with test) | |
| security: | |
| name: Security Audit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install mise and tools | |
| uses: jdx/mise-action@v2 | |
| with: | |
| install: true | |
| cache: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps/ | |
| _build/ | |
| key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ hashFiles('mise.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}- | |
| ${{ runner.os }}-mix- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Check for security vulnerabilities | |
| run: mix deps.audit | |
| # Dependency analysis (parallel with test) | |
| dependency_check: | |
| name: Dependency Analysis | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install mise and tools | |
| uses: jdx/mise-action@v2 | |
| with: | |
| install: true | |
| cache: true | |
| - name: Cache dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| deps/ | |
| _build/ | |
| key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}-${{ hashFiles('mise.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }}- | |
| ${{ runner.os }}-mix- | |
| - name: Install dependencies | |
| run: mix deps.get | |
| - name: Check dependency status | |
| run: mix hex.outdated | |
| # CI Results summary (inspired by WebSocket Bridge) | |
| results: | |
| name: CI Results | |
| runs-on: ubuntu-latest | |
| needs: [test, pre-commit, docs, security, dependency_check] | |
| if: always() | |
| steps: | |
| - name: Check job results | |
| run: | | |
| echo "Test job result: ${{ needs.test.result }}" | |
| echo "Pre-commit job result: ${{ needs.pre-commit.result }}" | |
| echo "Docs job result: ${{ needs.docs.result }}" | |
| echo "Security job result: ${{ needs.security.result }}" | |
| echo "Dependency check result: ${{ needs.dependency_check.result }}" | |
| if [[ "${{ needs.test.result }}" == "failure" || "${{ needs.pre-commit.result }}" == "failure" || "${{ needs.docs.result }}" == "failure" || "${{ needs.security.result }}" == "failure" || "${{ needs.dependency_check.result }}" == "failure" ]]; then | |
| echo "❌ CI Pipeline Failed" | |
| exit 1 | |
| else | |
| echo "✅ CI Pipeline Passed" | |
| fi |