-
Notifications
You must be signed in to change notification settings - Fork 1
151 lines (145 loc) · 4.77 KB
/
ci.yml
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: CI
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
setup:
name: asdf and Elixir dependencies
timeout-minutes: 30
runs-on: ubuntu-latest
outputs:
cache-key-asdf: ${{ steps.cache-keys.outputs.asdf }}
cache-key-mix: ${{ steps.cache-keys.outputs.mix }}
steps:
- uses: actions/checkout@v4
- name: Set cache keys
id: cache-keys
run: |
echo "asdf-restore=cache-asdf-" >> $GITHUB_OUTPUT
echo "asdf=cache-asdf-${{ hashFiles('.tool-versions') }}" >> $GITHUB_OUTPUT
echo "mix-restore=cache-mix-" >> $GITHUB_OUTPUT
echo "mix=cache-mix-${{ hashFiles('**/mix.lock', '.tool-versions') }}" >> $GITHUB_OUTPUT
- name: asdf cache
uses: actions/cache@v4
with:
path: ~/.asdf
key: ${{ steps.cache-keys.outputs.asdf }}
restore-keys: ${{ steps.cache-keys.outputs.asdf-restore }}
id: asdf-cache
- uses: asdf-vm/actions/install@v3
if: steps.asdf-cache.outputs.cache-hit != 'true'
- name: Setup asdf environment
uses: mbta/actions/reshim-asdf@v2
- name: mix rebar and hex
run: |
mix local.rebar --force
mix local.hex --force
if: steps.asdf-cache.outputs.cache-hit != 'true'
- name: Mix cache
id: deps-cache
uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ steps.cache-keys.outputs.mix }}
restore-keys: ${{ steps.cache-keys.outputs.mix-restore }}
- name: Install and compile Mix dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: |
mix deps.get
mix deps.compile
MIX_ENV=test mix deps.compile
build_elixir:
name: Build and test Elixir
timeout-minutes: 30
runs-on: ubuntu-latest
needs: setup
steps:
- name: asdf cache
uses: actions/cache/restore@v4
with:
path: ~/.asdf
key: ${{ needs.setup.outputs.cache-key-asdf }}
- name: Setup asdf environment
uses: mbta/actions/reshim-asdf@v2
- uses: actions/checkout@v4
- name: Restore Mix cache
uses: actions/cache/restore@v4
with:
path: |
deps
_build
key: ${{ needs.setup.outputs.cache-key-mix }}
- name: Compile (warnings as errors)
run: mix compile --force --warnings-as-errors
- name: Credo
run: mix credo --strict
- name: Check formatting
run: mix format --check-formatted
- name: Run tests
run: mix test --cover
- name: Report test coverage
# Disabled due to dependency issues
if: false
uses: mbta/github-actions-report-lcov@v1
with:
coverage-files: cover/lcov.info
artifact-name: code-coverage-report
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: mbta/actions/dialyzer@v2
- name: Check for unused dependencies
run: mix deps.unlock --check-unused
docker_build:
name: Check that the Docker container will build and run
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: docker build
uses: docker/build-push-action@v6
with:
context: .
push: false
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: docker compose build
run: docker compose build
- name: docker compose up
run: docker compose up --wait
env:
API_KEY: ${{secrets.API_KEY}}
API_URL: ${{secrets.API_URL}}
- name: ensure running properly
run: docker compose exec --no-TTY mobile-app-backend wget --spider -S http://localhost:4000/
- name: show docker container logs
run: docker compose logs mobile-app-backend
if: ${{ !cancelled() }}
load_test:
name: Check Python load tests for basic validity
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Read asdf versions
id: asdf
run: cat load_testing/.tool-versions | sed 's/ /=/' | tee -a "$GITHUB_OUTPUT"
- name: Install poetry
run: pipx install poetry==${{steps.asdf.outputs.poetry}}
- uses: actions/setup-python@v5
with:
python-version: ${{steps.asdf.outputs.python}}
cache: poetry
cache-dependency-path: load_testing/poetry.lock
- run: cd load_testing && poetry install
- run: cd load_testing && poetry run ruff check
- run: cd load_testing && poetry run mypy locustfile.py