File size: 3,558 Bytes
ee18265
 
 
 
 
 
 
 
82cacde
 
 
ee18265
 
 
 
 
 
 
d61a10c
82cacde
 
 
ee18265
 
 
 
 
82cacde
 
ee18265
 
 
 
 
4687df9
 
 
38f177d
 
 
 
 
ee18265
 
 
 
 
 
 
73b0ca7
9df0e7d
73b0ca7
 
ee18265
 
73b0ca7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee18265
 
 
 
73b0ca7
 
 
38f177d
 
 
 
9df0e7d
38f177d
 
 
 
 
ee18265
82cacde
 
3a052af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38f177d
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Create initial workflow based on GitHub's suggestion for Elixir.

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: Download Bumblebee model artifacts
      #   uses: actions/download-artifacts
      #   with:
      #     name: bumblebee-cache

      - 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 }}

      # - name: Upload Bumblebee model artifacts
      #   uses: actions/upload-artifact@v4
      #   with:
      #     name: bumblebee-cache
      #     path: $HOME/.cache/bumblebee