Skip to content

Improved TH generation #832

Improved TH generation

Improved TH generation #832

Workflow file for this run

env:
cache_generation: 2024-06-13
# NOTE: Please keep .mergify.yml in sync when adding or removing any jobs.
name: main
on: [pull_request]
jobs:
build:
strategy:
matrix:
os:
- runner: 'macOS-latest'
archive-command: 'tar --create --bzip2 --file'
file-extension: 'tar.bz2'
executable-extension: ''
- runner: 'macos-13'
archive-command: 'tar --create --bzip2 --file'
file-extension: 'tar.bz2'
executable-extension: ''
- runner: 'ubuntu-latest'
archive-command: 'tar --create --bzip2 --file'
file-extension: 'tar.bz2'
executable-extension: ''
- runner: 'windows-latest'
archive-command: '7z a -tzip'
file-extension: 'zip'
executable-extension: '.exe'
stack-yaml:
- "stack.yaml"
include:
- os:
runner: "ubuntu-latest"
stack-yaml: "stack.ghc-8.10.yaml"
- os:
runner: "ubuntu-latest"
stack-yaml: "stack.ghc-9.2.yaml"
- os:
runner: "ubuntu-latest"
stack-yaml: "stack.ghc-9.4.yaml"
fail-fast: false
name: ${{ matrix.os.runner }} - ${{ matrix.stack-yaml }}
runs-on: ${{ matrix.os.runner }}
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
submodules: true
- id: setup-haskell-cabal
name: "Setup Haskell environment"
uses: haskell-actions/[email protected]
with:
enable-stack: true
stack-version: "latest"
stack-no-global: true
- name: "Cache"
uses: actions/cache@v4
with:
key: ${{ matrix.os.runner }}-${{ runner.arch }}-${{ env.cache_generation }}-${{ hashFiles(matrix.stack-yaml) }}
restore-keys: |
${{ matrix.os.runner }}-${{ runner.arch }}-${{ env.cache_generation }}-
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
echo "::debug::'pkg-config libsodium' output:"
pkg-config --print-errors --libs libsodium || true
- 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 --stack-yaml "${{matrix.stack-yaml}}" 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 --stack-yaml "${{matrix.stack-yaml}}" test "${package}"
done
- name: "Prepare packaging"
if: ${{ matrix.stack-yaml == 'stack.yaml' }}
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"
if: ${{ matrix.stack-yaml == 'stack.yaml' }}
shell: bash
run: |
packages=(
dhall
dhall-bash
dhall-csv
dhall-docs
dhall-json
dhall-lsp-server
dhall-nix
dhall-openapi
dhall-toml
dhall-yaml
)
function package() (
local package="${1}"
local version="$(stack query locals "${package}" version)"
shift
local assets=("${@}")
local package_file="${package}-${version}-${{ runner.os }}-${{ runner.arch }}.${{ 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"
if: ${{ matrix.stack-yaml == 'stack.yaml' }}
uses: actions/upload-artifact@v4
with:
name: 'dhall-${{ runner.os }}-${{ runner.arch }}.${{ matrix.os.file-extension }}'
path: 'dhall-*${{ runner.os }}-${{ runner.arch }}.${{ matrix.os.file-extension }}'