Merged all workflows together using build matrixes

This commit is contained in:
evandrocoan 2020-03-26 01:40:53 -03:00
parent e1252b785d
commit 96d572c3cc

View file

@ -3,175 +3,73 @@ name: Checks
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
linux_tests: tests:
runs-on: ubuntu-latest name: Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
SEP: /
PIP_WHEELS_DIR: ~/.cache/pip
CARGO_INDEX_DIR: ~/.cargo/git
CARGO_REGISTRY_DIR: ~/.cargo/registry
ANKI_PYTHON_WHEELS: anki_linux_python_wheels
- os: macos-latest
SEP: /
PIP_WHEELS_DIR: ~/Library/Caches/pip
CARGO_INDEX_DIR: ~/.cargo/git
CARGO_REGISTRY_DIR: ~/.cargo/registry
ANKI_PYTHON_WHEELS: anki_mac os_python_wheels
- os: windows-latest
SEP: \
PIP_WHEELS_DIR: ~\AppData\Local\pip\Cache
CARGO_INDEX_DIR: C:\Rust\.cargo\git
CARGO_REGISTRY_DIR: C:\Rust\.cargo\registry
ANKI_PYTHON_WHEELS: anki_windows_python_wheels
steps: steps:
- run: git config --global core.autocrlf false
if: matrix.os == 'windows-latest'
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Configure environment variables
- name: Configure Linux environment variables
if: matrix.os == 'ubuntu-latest'
run: | run: |
# echo "::set-env name=SHELLFLAGS::-x" # echo "::set-env name=SHELLFLAGS::-x"
echo "::set-env name=BUILDFLAGS::" echo "::set-env name=BUILDFLAGS::"
echo "::set-env name=RSPY_TARGET_DIR::${GITHUB_WORKSPACE}/target" echo "::set-env name=RSPY_TARGET_DIR::${GITHUB_WORKSPACE}/target"
echo "::set-env name=CARGO_TARGET_DIR::${GITHUB_WORKSPACE}/target" echo "::set-env name=CARGO_TARGET_DIR::${GITHUB_WORKSPACE}/target"
# Necessary for now for the cargo cache:
# https://github.com/actions/cache/issues/133#issuecomment-599102035
- name: Fix ~/.cache permissions
run: |
sudo chown -R $(whoami):$(id -ng) ~/.cargo/
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo target
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo rslib
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/rslib/target
key: ${{ runner.os }}-cargo-rslib-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo rspy
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/rspy/target
key: ${{ runner.os }}-cargo-rspy-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache pip wheels
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-8-
- name: Cache pyenv
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/pyenv
key: ${{ runner.os }}-pyenv-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/requirements.txt') }}-8-
- name: Set up python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set up protoc
uses: ankitects/setup-protoc@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 12
- name: Set up ripgrep, pyaudio, gettext, rename
run: |
sudo apt update
sudo apt install portaudio19-dev gettext rename
sudo snap install ripgrep --classic
- run: make develop
- run: make build
- run: make check
- name: Upload python wheels
uses: actions/upload-artifact@v1
with:
name: anki_linux_python_wheels
path: dist
- name: Configure Mac OS environment variables
mac_os_tests: if: matrix.os == 'macos-latest'
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Configure environment variables
run: | run: |
# echo "::set-env name=SHELLFLAGS::-x" # echo "::set-env name=SHELLFLAGS::-x"
echo "::set-env name=BUILDFLAGS::" echo "::set-env name=BUILDFLAGS::"
# Update make to use the new `.SHELLFLAGS` feature # Update make to use the new `.SHELLFLAGS` feature
# https://stackoverflow.com/questions/43175529/updating-make-version-4-1-on-mac # https://stackoverflow.com/questions/43175529/updating-make-version-4-1-on-mac
echo "::set-env name=PATH::/usr/local/opt/make/libexec/gnubin:$PATH" echo "::set-env name=PATH::/usr/local/opt/make/libexec/gnubin:$PATH"
# Disabled for Mac OS because it was not reusing the cached files # Disabled for Mac OS because it was not reusing the cached files
# https://github.com/ankitects/anki/pull/528 # https://github.com/ankitects/anki/pull/528
# echo "::set-env name=RSPY_TARGET_DIR::${GITHUB_WORKSPACE}/target" # echo "::set-env name=RSPY_TARGET_DIR::${GITHUB_WORKSPACE}/target"
# echo "::set-env name=CARGO_TARGET_DIR::${GITHUB_WORKSPACE}/target" # echo "::set-env name=CARGO_TARGET_DIR::${GITHUB_WORKSPACE}/target"
# Necessary for now for the cargo cache:
# https://github.com/actions/cache/issues/133#issuecomment-599102035
- name: Fix ~/.cache permissions
run: |
sudo chown -R $(whoami):$(id -ng) ~/.cargo/
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo target
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo rslib
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/rslib/target
key: ${{ runner.os }}-cargo-rslib-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo rspy
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/rspy/target
key: ${{ runner.os }}-cargo-rspy-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache pip wheels
uses: actions/cache@v1
with:
path: ~/Library/Caches/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-8-
- name: Cache pyenv
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/pyenv
key: ${{ runner.os }}-pyenv-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/requirements.txt') }}-8-
- name: Set up python
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Set up protoc
uses: ankitects/setup-protoc@master
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up node
uses: actions/setup-node@v1
with:
node-version: 12
- name: Set up brew packages
run: |
brew install portaudio protobuf gettext rename ripgrep make
brew link gettext --force
- run: make develop
- run: make build
- run: make check
- name: Upload python wheels
uses: actions/upload-artifact@v1
with:
name: anki_mac_os_python_wheels
path: dist
- name: Configure Windows environment variables
windows_tests: if: matrix.os == 'windows-latest'
runs-on: windows-latest
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v2
- name: Configure environment variables
run: | run: |
# echo "::set-env name=SHELLFLAGS::-x" # echo "::set-env name=SHELLFLAGS::-x"
echo "::set-env name=BUILDFLAGS::"
$pyaudio=("PyAudio-0.2.11-cp37-cp37m-win_amd64.whl") $pyaudio=("PyAudio-0.2.11-cp37-cp37m-win_amd64.whl")
$new_path=("$env:GITHUB_WORKSPACE;$env:PATH") $new_path=("$env:GITHUB_WORKSPACE;$env:PATH")
$new_path=("$env:GITHUB_WORKSPACE\shims;$new_path") $new_path=("$env:GITHUB_WORKSPACE\shims;$new_path")
echo "::set-env name=pacmanbin::pacman-5.1.1-3-x86_64.pkg.tar.xz" echo "::set-env name=pacmanbin::pacman-5.1.1-3-x86_64.pkg.tar.xz"
echo "::set-env name=pacmanmirror::pacman-mirrors-20200307-1-any.pkg.tar.xz" echo "::set-env name=pacmanmirror::pacman-mirrors-20200307-1-any.pkg.tar.xz"
echo "::set-env name=pacmankeys::msys2-keyring-r9.397a52e-1-any.pkg.tar.xz" echo "::set-env name=pacmankeys::msys2-keyring-r9.397a52e-1-any.pkg.tar.xz"
@ -181,62 +79,80 @@ jobs:
echo "::set-env name=SCOOP::$env:GITHUB_WORKSPACE" echo "::set-env name=SCOOP::$env:GITHUB_WORKSPACE"
echo "::set-env name=SCOOP_GLOBAL::$env:GITHUB_WORKSPACE" echo "::set-env name=SCOOP_GLOBAL::$env:GITHUB_WORKSPACE"
echo "::set-env name=ANKI_EXTRA_PIP::python -m pip install $pyaudio" echo "::set-env name=ANKI_EXTRA_PIP::python -m pip install $pyaudio"
echo "::set-env name=BUILDFLAGS::"
echo "::set-env name=RSPY_TARGET_DIR::$env:GITHUB_WORKSPACE\target" echo "::set-env name=RSPY_TARGET_DIR::$env:GITHUB_WORKSPACE\target"
echo "::set-env name=CARGO_TARGET_DIR::$env:GITHUB_WORKSPACE\target" echo "::set-env name=CARGO_TARGET_DIR::$env:GITHUB_WORKSPACE\target"
- name: Cache pyenv
uses: actions/cache@v1 # Necessary for now for the cargo cache:
with: # https://github.com/actions/cache/issues/133#issuecomment-599102035
path: ${{ github.workspace }}\pyenv - name: Fix ~/.cache permissions
key: ${{ runner.os }}-pyenv-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/requirements.txt') }}-8- if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
- name: Cache cargo registry run: |
uses: actions/cache@v1 sudo chown -R $(whoami):$(id -ng) ~/.cargo/
with:
path: C:\Rust\.cargo\registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo index
uses: actions/cache@v1
with:
path: C:\Rust\.cargo\git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo target
uses: actions/cache@v1
with:
path: ${{ github.workspace }}\target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo rslib
uses: actions/cache@v1
with:
path: ${{ github.workspace }}\rslib\target
key: ${{ runner.os }}-cargo-rslib-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo rspy
uses: actions/cache@v1
with:
path: ${{ github.workspace }}\rspy\target
key: ${{ runner.os }}-cargo-rspy-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache pip wheels - name: Cache pip wheels
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
path: ~\AppData\Local\pip\Cache path: ${{ matrix.PIP_WHEELS_DIR }}
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-8- key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-8-
- name: Cache pyenv
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}pyenv
key: ${{ runner.os }}-pyenv-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/requirements.txt') }}-8-
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ${{ matrix.CARGO_INDEX_DIR }}
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ${{ matrix.CARGO_REGISTRY_DIR }}
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo target
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo rslib
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}rslib${{ matrix.SEP }}target
key: ${{ runner.os }}-cargo-rslib-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache cargo rspy
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}rspy${{ matrix.SEP }}target
key: ${{ runner.os }}-cargo-rspy-${{ hashFiles('**/Cargo.toml') }}-8-
- name: Cache pacman - name: Cache pacman
if: matrix.os == 'windows-latest'
uses: actions/cache@v1 uses: actions/cache@v1
id: cache-pacman id: cache-pacman
with: with:
path: C:\Program Files\Git path: C:\Program Files\Git
key: ${{ runner.os }}-pacman-${{ hashFiles('**/checks.yml') }}-8- key: ${{ runner.os }}-pacman-${{ hashFiles('**/checks.yml') }}-8-
- name: Set up pacman, rsync - name: Set up pacman, rsync
if: steps.cache-pacman.outputs.cache-hit != 'true' if: matrix.os == 'windows-latest' && steps.cache-pacman.outputs.cache-hit != 'true'
shell: cmd shell: cmd
run: | run: |
echo on echo on
curl -LO http://repo.msys2.org/msys/x86_64/%pacmanbin% curl -LO http://repo.msys2.org/msys/x86_64/%pacmanbin%
curl -LO http://repo.msys2.org/msys/x86_64/%pacmanmirror% curl -LO http://repo.msys2.org/msys/x86_64/%pacmanmirror%
curl -LO http://repo.msys2.org/msys/x86_64/%pacmankeys% curl -LO http://repo.msys2.org/msys/x86_64/%pacmankeys%
:: https://stackoverflow.com/questions/1359793/programmatically-extract-tar-gz :: https://stackoverflow.com/questions/1359793/programmatically-extract-tar-gz
7z x "%pacmanbin%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git" 7z x "%pacmanbin%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git"
7z x "%pacmanmirror%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git" 7z x "%pacmanmirror%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git"
7z x "%pacmankeys%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git" 7z x "%pacmankeys%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git"
:: Manually Install Pacman Binaries :: Manually Install Pacman Binaries
:: https://github.com/Alexpux/MSYS2-pacman/issues/50 :: https://github.com/Alexpux/MSYS2-pacman/issues/50
set "PATH=%programfiles%\Git\usr\bin" set "PATH=%programfiles%\Git\usr\bin"
@ -247,43 +163,67 @@ jobs:
pacman -Syyuuv --overwrite='*' pacman -Syyuuv --overwrite='*'
pacman -Syuuv --overwrite='*' pacman -Syuuv --overwrite='*'
pacman --version pacman --version
:: We must install bash first, otherwise we will have bash fork errors: :: We must install bash first, otherwise we will have bash fork errors:
:: https://github.com/evandroforks/anki/runs/524857054?check_suite_focus=true :: https://github.com/evandroforks/anki/runs/524857054?check_suite_focus=true
:: 0 [main] pacman 748 dofork: child -1 - forked process 2896 died unexpectedly :: 0 [main] pacman 748 dofork: child -1 - forked process 2896 died unexpectedly
pacman -Sv --noconfirm --overwrite='*' bash pacman -Sv --noconfirm --overwrite='*' bash
pacman -Sv --noconfirm --overwrite='*' rsync pacman -Sv --noconfirm --overwrite='*' rsync
:: clean all packages to decrease image size :: clean all packages to decrease image size
pacman -Sccv --noconfirm pacman -Sccv --noconfirm
pacman -Qsv --noconfirm pacman -Qsv --noconfirm
- name: Set up pyaudio, rename - name: Set up pyaudio, rename
if: matrix.os == 'windows-latest'
shell: cmd shell: cmd
run: | run: |
echo on echo on
curl -LO https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/%pyaudio% curl -LO https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/%pyaudio%
curl -LO https://raw.githubusercontent.com/subogero/rename/master/rename curl -LO https://raw.githubusercontent.com/subogero/rename/master/rename
- name: Set up scoop, gettext, ripgrep - name: Set up scoop, gettext, ripgrep
if: matrix.os == 'windows-latest'
shell: cmd shell: cmd
run: | run: |
echo on echo on
powershell -executionpolicy bypass "& Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')" powershell -executionpolicy bypass "& Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')"
scoop install -g gettext ripgrep scoop install -g gettext ripgrep
- name: Set up ripgrep, pyaudio, gettext, rename
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install portaudio19-dev gettext rename
sudo snap install ripgrep --classic
- name: Set up brew packages
if: matrix.os == 'macos-latest'
run: |
brew install portaudio protobuf gettext rename ripgrep make
brew link gettext --force
- name: Set up python - name: Set up python
uses: actions/setup-python@v1 uses: actions/setup-python@v1
with: with:
python-version: 3.7 python-version: 3.7
- name: Set up protoc - name: Set up protoc
uses: ankitects/setup-protoc@master uses: ankitects/setup-protoc@master
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up node - name: Set up node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 12 node-version: 12
- run: make develop - run: make develop
- run: make build - run: make build
- run: make check - run: make check
- name: Upload python wheels - name: Upload python wheels
uses: actions/upload-artifact@v1 uses: actions/upload-artifact@v1
with: with:
name: anki_windows_python_wheels name: ${{ matrix.ANKI_PYTHON_WHEELS }}
path: dist path: dist