noahsettersten commited on
Commit
3a052af
1 Parent(s): 30233a2

ci: Gather and report test coverage in test workflow

Browse files
Files changed (1) hide show
  1. .github/workflows/test.yml +22 -1
.github/workflows/test.yml CHANGED
@@ -94,7 +94,28 @@ jobs:
94
  - name: Run tests
95
  env:
96
  DATABASE_URL: postgresql://postgres:postgres@localhost/medical_transcription_test
97
- run: mix test
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  # - name: Upload Bumblebee model artifacts
100
  # uses: actions/upload-artifact@v4
 
94
  - name: Run tests
95
  env:
96
  DATABASE_URL: postgresql://postgres:postgres@localhost/medical_transcription_test
97
+ run: mix test --cover --export-coverage default
98
+
99
+ - name: Export code coverage
100
+ id: coverage_percent
101
+ run: |
102
+ COVERAGE_RESULTS=$(mix test.coverage) || true
103
+ echo $COVERAGE_RESULTS
104
+
105
+ COVERAGE_PERCENTAGE=$(echo $COVERAGE_RESULTS | grep "Coverage:" | awk -F ':' '{print $2}' | awk '{$1=$1;print}')
106
+ echo "value=$COVERAGE_PERCENTAGE" >> $GITHUB_OUTPUT
107
+
108
+ - name: Send coverage results to Slack
109
+ uses: slackapi/slack-github-action@v1.23.0
110
+ if: ${{ github.ref == 'refs/head/main' }}
111
+ with:
112
+ payload: |
113
+ {
114
+ "appName": "MediCode",
115
+ "percent": "${{ steps.coverage_percent.outputs.value }}"
116
+ }
117
+ env:
118
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
119
 
120
  # - name: Upload Bumblebee model artifacts
121
  # uses: actions/upload-artifact@v4