-
-
Save PJUllrich/98b72de7dc0041b1f02c6e4f4652a7e2 to your computer and use it in GitHub Desktop.
| name: Elixir CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| services: | |
| db: | |
| image: postgres:11 | |
| ports: ["5432:5432"] | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/[email protected] | |
| - uses: actions/[email protected] | |
| with: | |
| otp-version: 22.0 | |
| elixir-version: 1.9.4 | |
| - uses: actions/setup-node@v1 | |
| with: | |
| node-version: 12 | |
| - name: Install chromedriver | |
| run: | | |
| wget https://chromedriver.storage.googleapis.com/78.0.3904.105/chromedriver_linux64.zip | |
| unzip chromedriver_linux64.zip | |
| sudo mv chromedriver /usr/bin/chromedriver | |
| sudo chown root:root /usr/bin/chromedriver | |
| sudo chmod +x /usr/bin/chromedriver | |
| # Cache NPM packages | |
| - name: Retrieve NPM Packages Cache | |
| uses: actions/cache@v1 | |
| id: npm-cache | |
| with: | |
| path: assets/node_modules | |
| key: ${{ runner.os }}-npm-${{ hashFiles(format('{0}{1}', github.workspace, '/assets/package-lock.json')) }} | |
| # Install NPM Packages only if cache was not hit | |
| - name: Install NPM Packages | |
| if: steps.npm-cache.outputs.cache-hit != 'true' | |
| run: npm install --prefix assets | |
| # Cache Mix Dependencies based on mix.lock | |
| - name: Retrieve Mix Dependencies Cache | |
| uses: actions/cache@v1 | |
| id: mix-cache | |
| with: | |
| path: deps | |
| key: ${{ runner.os }}-mix-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
| # Get Mix Dependencies only if cache was not hit | |
| - name: Install Mix Dependencies | |
| if: steps.mix-cache.outputs.cache-hit != 'true' | |
| run: | | |
| mix local.rebar --force | |
| mix local.hex --force | |
| mix deps.get | |
| # Compile and deploy assets to priv | |
| - name: Deploy assets | |
| run: npm run deploy --prefix ./assets | |
| # Cache the _build folder | |
| - name: Retrieve Build Cache | |
| uses: actions/cache@v1 | |
| id: build-cache | |
| with: | |
| path: _build | |
| key: ${{ runner.os }}-build-${{ hashFiles(format('{0}{1}', github.workspace, '/mix.lock')) }} | |
| # Compile mix dependencies if the _build folder was not cached | |
| - name: Compile Mix Dependencies | |
| if: steps.build-cache.outputs.cache-hit != 'true' | |
| run: MIX_ENV=test mix deps.compile | |
| # Run the tests | |
| - name: Run Tests | |
| run: mix test |
Uh! Yes! That's a great idea! I'll steal that from you if you don't mind :P
Of course, I don't mind :) That's why I am sharing it :) And to let you know that I've found your setup with separate step for compiling deps very useful! :)
I also added Dialyxir to my setup with separate step for compiling PLTs and another one for actual check: https://github.com/tomekowal/composable_html/blob/master/.github/workflows/elixir.yml
The dialyzer part is not perfect because it requires repeating priv/plts in elixir.yml and mix.exs but does the job :)
Wow, lots of good thing here, thank you!
Unless you need a specific version of Chrome/Driver, it's installed by default on ubuntu-latest
https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1804-README.md
Wow, lots of good thing here, thank you!
Unless you need a specific version of Chrome/Driver, it's installed by default onubuntu-latest
https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1804-README.md
Good work. Thanks
Pretty great setup! Compiling deps first and then the code is a neat trick.
I am using this file as a reference :)
I only changed one thing. I've added elixir and OTP versions to cache keys. I used matrix strategy for that even though there will be only one build in the matrix.