livebook/.github/workflows/test.yml
2024-08-09 19:12:20 +02:00

139 lines
4.5 KiB
YAML

name: Test
on:
pull_request:
push:
branches:
- main
- "v*.*"
jobs:
main:
runs-on: ubuntu-latest
env:
MIX_ENV: test
ELIXIR_ERL_OPTIONS: "-epmd_module Elixir.Livebook.EPMD"
steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: Read ./versions
run: |
. versions
echo "elixir=$elixir" >> $GITHUB_ENV
echo "otp=$otp" >> $GITHUB_ENV
echo "openssl=$openssl" >> $GITHUB_ENV
- name: Install Erlang & Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.otp }}
elixir-version: ${{ env.elixir }}
- name: Cache Mix
uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-
- name: Install mix dependencies
run: mix deps.get
- name: Check formatting
run: mix format --check-formatted
- name: Check warnings
run: mix compile --warnings-as-errors
- name: Run tests
run: mix test
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: "20.x"
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
run: npm ci --prefix assets
- name: Check assets formatting
run: npm run format-check --prefix assets
- name: Run assets tests
run: npm test --prefix assets
windows:
runs-on: windows-latest
if: github.event_name == 'push'
env:
MIX_ENV: test
ELIXIR_ERL_OPTIONS: "-epmd_module Elixir.Livebook.EPMD"
steps:
- name: Configure Git
run: git config --global core.autocrlf input
- name: Checkout git repo
uses: actions/checkout@v4
- name: Read ./versions
shell: bash
run: |
. versions
echo "elixir=$elixir" >> $GITHUB_ENV
echo "otp=$otp" >> $GITHUB_ENV
echo "openssl=$openssl" >> $GITHUB_ENV
- name: Install Erlang & Elixir
uses: erlef/setup-beam@v1
with:
version-type: strict
otp-version: ${{ env.otp }}
elixir-version: ${{ env.elixir }}
- name: Start epmd
run: $(elixir -e 'IO.puts "#{:code.root_dir()}/erts-#{:erlang.system_info(:version)}"')/bin/epmd.exe -daemon
shell: bash
# Add tar that supports symlinks, see https://github.com/actions/virtual-environments/issues/4679
- name: Add tar.exe
run: |
"C:\Program Files\Git\usr\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Cache Mix
uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-${{ hashFiles('**/mix.lock') }}
# Reinstalling deps fails on Windows in rare cases, so we always use a new cache
# restore-keys: |
# ${{ runner.os }}-mix-${{ env.elixir }}-${{ env.otp }}-
- name: Install mix dependencies
run: mix deps.get
- name: Run tests
run: mix test
- name: Build the app
run: bash .github/scripts/app/build_windows.sh
macos:
runs-on: macos-latest
if: github.event_name == 'push'
steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: Read ./versions
run: |
. versions
echo "elixir=$elixir" >> $GITHUB_ENV
echo "otp=$otp" >> $GITHUB_ENV
echo "openssl=$openssl" >> $GITHUB_ENV
- name: Cache Mix Deps
uses: actions/cache@v4
with:
path: deps
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
- name: Cache Bootstrap OTP
uses: actions/cache@v4
with:
path: elixirkit/otp_bootstrap/_build/otp-rel-${{ env.otp }}-openssl-${{ env.openssl }}-macos-universal
key: ${{ runner.os }}-bootstrap-${{ env.otp }}-${{ hashFiles('elixirkit/otp_bootstrap/build.sh') }}
- name: Cache Elixir
uses: actions/cache@v4
with:
path: _build/elixir-${{ env.elixir }}
key: ${{ runner.os }}-elixir-${{ env.elixir }}
- name: Build the app
run: .github/scripts/app/build_macos.sh