diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ea6a32fb..9bf4e87f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,3 +1,4 @@ +name: Test on: push jobs: @@ -9,5 +10,43 @@ jobs: with: version-type: strict version-file: .tool-versions + - name: Cache deps + id: cache-deps + uses: actions/cache@v3 + 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 }}- + + # Step: Define how to cache the `_build` directory. After the first run, + # this speeds up tests runs a lot. This includes not re-compiling our + # project's downloaded deps every run. + - name: Cache compiled build + id: cache-build + uses: actions/cache@v3 + 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- + + # Step: Conditionally bust the cache when job is re-run. + # Sometimes, we may have issues with incremental builds that are fixed by + # doing a full recompile. In order to not waste dev time on such trivial + # issues (while also reaping the time savings of incremental builds for + # *most* day-to-day development), force a full recompile only on builds + # that are retried. + - name: Clean to rule out incremental build as a source of flakiness + if: github.run_attempt != '1' + run: | + mix deps.clean --all + mix clean + shell: sh - run: mix deps.get - run: mix test diff --git a/README.md b/README.md index 5a559c4e..90ce160d 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,7 @@ Ready to run in production? Please [check our deployment guides](https://hexdocs ``` Note that this query would fail to disambiguate artists with the same name - can be fixed by using the artist `musicbrainz_id`. + +### CI + +See the `.github` folder.