Add ARM runner action. Remove Windows and macOS builds. #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env: | |
cache_generation: 2021-06-22 | |
# NOTE: Please keep .mergify.yml in sync when adding or removing any jobs. | |
name: main | |
on: [pull_request] | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: | |
- runner: 'ubuntu-latest' | |
archive-command: 'tar --create --bzip2 --file' | |
file-extension: 'tar.bz2' | |
executable-extension: '' | |
fail-fast: false | |
name: ${{ matrix.os.runner }} | |
runs-on: ${{ matrix.os.runner }} | |
steps: | |
- name: "Checkout repository" | |
uses: actions/checkout@v2 | |
with: | |
submodules: true | |
- uses: pguyot/arm-runner-action@v2 | |
- id: setup-haskell-cabal | |
name: "Setup Haskell environment" | |
uses: haskell/actions/[email protected] | |
with: | |
enable-stack: true | |
- name: "Cache" | |
uses: actions/cache@v2 | |
with: | |
key: ${{ matrix.os.runner }}-${{ hashFiles('stack.yaml') }}-${{ env.cache_generation }} | |
restore-keys: | | |
${{ matrix.os.runner }}- | |
path: | | |
${{ steps.setup-haskell-cabal.outputs.stack-root }} | |
- name: Install libsodium | |
shell: bash | |
run: | | |
if [ '${{matrix.os.runner}}' == 'ubuntu-latest' ]; then | |
sudo apt-get install -y libsodium-dev | |
fi | |
- name: "Build" | |
shell: bash | |
run: | | |
packages=( | |
dhall | |
dhall-bash | |
dhall-csv | |
dhall-docs | |
dhall-json | |
dhall-lsp-server | |
dhall-nix | |
dhall-openapi | |
dhall-toml | |
dhall-yaml | |
) | |
for package in "${packages[@]}"; do | |
if [ '${{matrix.os.runner}}' == 'windows-latest' ] && [ "${package}" == 'dhall-nix' ]; then | |
continue | |
fi | |
# We use --test --no-run-tests to avoid re-building all the local packages in the | |
# subsequent test step. | |
# See https://github.com/commercialhaskell/stack/issues/4977. | |
stack build --test --no-run-tests --copy-bins --local-bin-path ./bin "${package}" | |
done | |
- name: "Run tests" | |
shell: bash | |
run: | | |
packages=( | |
dhall | |
dhall-bash | |
dhall-csv | |
dhall-docs | |
dhall-json | |
dhall-lsp-server | |
dhall-nix | |
dhall-openapi | |
dhall-toml | |
dhall-yaml | |
) | |
for package in "${packages[@]}"; do | |
if [ '${{matrix.os.runner}}' == 'windows-latest' ] && [ "${package}" == 'dhall-nix' ]; then | |
continue | |
fi | |
stack test "${package}" | |
done | |
- name: "Prepare packaging" | |
shell: bash | |
run: | | |
mkdir -p share/man/man1 | |
cp dhall/man/dhall.1 share/man/man1/ | |
cp dhall-docs/src/Dhall/data/man/dhall-docs.1 share/man/man1/ | |
- id: package | |
name: "Create packages" | |
shell: bash | |
run: | | |
packages=( | |
dhall | |
dhall-bash | |
dhall-csv | |
dhall-docs | |
dhall-json | |
dhall-lsp-server | |
dhall-nix | |
dhall-openapi | |
dhall-toml | |
dhall-yaml | |
) | |
architecture="$(uname -m)" | |
function package() ( | |
local package="${1}" | |
local version="$(stack query locals "${package}" version)" | |
shift | |
local assets=("${@}") | |
local package_file="${package}-${version}-${architecture}-${{runner.os}}.${{ matrix.os.file-extension }}" | |
${{matrix.os.archive-command}} "${package_file}" "${assets[@]}" | |
) | |
exe='${{matrix.os.executable-extension}}' | |
package 'dhall' "bin/dhall${exe}" 'share/man/man1/dhall.1' | |
package 'dhall-bash' "bin/dhall-to-bash${exe}" | |
package 'dhall-csv' "bin/csv-to-dhall${exe}" "bin/dhall-to-csv${exe}" | |
package 'dhall-docs' "bin/dhall-docs${exe}" 'share/man/man1/dhall-docs.1' | |
package 'dhall-json' "bin/dhall-to-json${exe}" "bin/dhall-to-yaml${exe}" "bin/json-to-dhall${exe}" | |
package 'dhall-lsp-server' "bin/dhall-lsp-server${exe}" | |
if [ '${{matrix.os.runner}}' != 'windows-latest' ]; then | |
package 'dhall-nix' "bin/dhall-to-nix${exe}" | |
fi | |
package 'dhall-openapi' "bin/openapi-to-dhall${exe}" | |
package 'dhall-toml' "bin/dhall-to-toml${exe}" "bin/toml-to-dhall${exe}" | |
package 'dhall-yaml' "bin/dhall-to-yaml-ng${exe}" "bin/yaml-to-dhall${exe}" | |
- name: "Upload package" | |
uses: actions/upload-artifact@v2 | |
with: | |
name: 'dhall-${{runner.os}}.${{matrix.os.file-extension}}' | |
path: 'dhall-*${{runner.os}}.${{matrix.os.file-extension}}' |