| |
|
|
| on: |
| push: |
| branches: ["main"] |
| pull_request: |
| branches: ["main"] |
|
|
| env: |
| MIX_ENV: test |
|
|
| jobs: |
| test: |
| name: Test codebase |
| runs-on: ubuntu-latest |
|
|
| services: |
| postgres: |
| image: pgvector/pgvector:pg16 |
| env: |
| POSTGRES_USERNAME: postgres |
| POSTGRES_PASSWORD: postgres |
| 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: Install ffmpeg |
| run: sudo apt-get install ffmpeg |
|
|
| |
| |
| |
| |
|
|
| - name: Set up Elixir |
| uses: erlef/setup-beam@v1 |
| with: |
| elixir-version: '1.16.0' |
| otp-version: '26.0' |
|
|
| - name: Cache dependencies |
| id: cache-deps |
| uses: actions/cache@v4 |
| 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 }}- |
|
|
| - name: Cache compiled build |
| id: cache-build |
| uses: actions/cache@v4 |
| 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- |
| |
| - name: Clean dependencies to rule out incremental build as source of failures |
| if: github.run_attempt != '1' |
| run: | |
| mix deps.clean --all |
| mix clean |
| shell: sh |
|
|
| - name: Install dependencies |
| run: mix deps.get |
|
|
| - name: Compile |
| run: mix compile |
|
|
| - name: Print out Bumblebee cache directory |
| run: elixir -e 'IO.puts(:filename.basedir(:user_cache, "bumblebee"))' |
|
|
| - name: Cache Bumblebee model files |
| uses: actions/cache@v4 |
| with: |
| path: /home/runner/.cache/bumblebee |
| key: ${{ runner.os }}-bumblebee-${{ hashFiles('**/application.ex') }} |
| restore-keys: ${{ runner.os }}-bumblebee- |
|
|
| - name: Run tests |
| env: |
| DATABASE_URL: postgresql://postgres:postgres@localhost/medical_transcription_test |
| run: mix test --cover --export-coverage default |
|
|
| - name: Export code coverage |
| id: coverage_percent |
| run: | |
| COVERAGE_RESULTS=$(mix test.coverage) || true |
| echo $COVERAGE_RESULTS |
| |
| COVERAGE_PERCENTAGE=$(echo $COVERAGE_RESULTS | grep "Coverage:" | awk -F ':' '{print $2}' | awk '{$1=$1;print}') |
| echo "value=$COVERAGE_PERCENTAGE" >> $GITHUB_OUTPUT |
|
|
| - name: Send coverage results to Slack |
| uses: slackapi/slack-github-action@v1.23.0 |
| if: ${{ github.ref == 'refs/head/main' }} |
| with: |
| payload: | |
| { |
| "appName": "MediCode", |
| "percent": "${{ steps.coverage_percent.outputs.value }}" |
| } |
| env: |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
|
|
| |
| |
| |
| |
| |
|
|