Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to use local actions #10503

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions .github/actions/cabal-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
name: Cabal setup
description: Set up a workflow for Cabal

inputs:
ghc:
description: ghc version to use
required: true
extra-ghc:
description: additional ghc for tests
required: false
default: ''
project:
description: which cabal.project to use
required: false
default: 'validate'
allow-newer:
description: allow-newer line
required: false
default: ''
constraints:
description: constraints line
required: false
default: ''
static:
description: whether to build statically
required: false
default: 'false'
shell:
description: shell to use
required: false
default: 'bash'
with_cache:
description: whether to instantiate cache
required: false
default: 'true'

outputs:
ghc-exe:
description: Path to ghc installed by setup-haskell
value: ${{ steps.setup-haskell.outputs.ghc-exe }}

runs:
using: composite
steps:
- name: Make sure ghc is specified
if: inputs.ghc == ''
shell: ${{ inputs.shell }}
run: exit 1

- name: Work around existence of XDG directories (haskell-actions/setup#62)
if: runner.os == 'macOS'
shell: ${{ inputs.shell }}
run: |
rm -rf ~/.config/cabal
rm -rf ~/.cache/cabal

- name: "WIN: Setup TMP environment variable"
if: runner.os == 'Windows'
shell: ${{ inputs.shell }}
run: |
echo "TMP=${{ runner.temp }}" >> "$GITHUB_ENV"

# See https://github.com/haskell/cabal/blob/master/CONTRIBUTING.md#hackage-revisions
- name: Add manually supplied allow-newer
if: inputs.allow-newer != ''
shell: ${{ inputs.shell }}
run: |
echo "allow-newer: ${{ inputs.allow-newer }}" >> cabal.${{ inputs.project }}.project

- name: Add manually supplied constraints
if: inputs.constraints != ''
shell: ${{ inputs.shell }}
run: |
echo "constraints: ${{ inputs.constraints }}" >> cabal.${{ inputs.project }}.project

- name: Enable statically linked executables
if: inputs.static == 'true'
shell: ${{ inputs.shell }}
run: |
echo 'executable-static: true' >> cabal.${{ inputs.project }}.project

# must happen before the main setup so the correct ghc is default
- name: Install extra ghc for tests
if: inputs.extra-ghc != ''
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ inputs.extra-ghc }}
cabal-version: '3.12.1.0' # see https://github.com/haskell/cabal/pull/10251

- uses: haskell-actions/setup@v2
id: setup-haskell
with:
ghc-version: ${{ inputs.ghc }}
cabal-version: '3.12.1.0'
# do we use this?
ghcup-release-channel: https://raw.githubusercontent.com/haskell/ghcup-metadata/master/ghcup-prereleases-0.0.8.yaml

# See the following link for a breakdown of the following step
# https://github.com/haskell/actions/issues/7#issuecomment-745697160
- uses: actions/cache@v4
if: inputs.with_cache != 'false'
with:
# validate.sh uses a special build dir
path: |
${{ steps.setup-haskell.outputs.cabal-store }}
dist-*
key: ${{ runner.os }}-${{ inputs.ghc }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ inputs.ghc }}-

# Needed by cabal-testsuite/PackageTests/Configure/setup.test.hs
- name: "MAC: Install Autotools"
if: runner.os == 'macOS'
shell: ${{ inputs.shell }}
run: |
brew install automake

# Needed by cabal-testsuite/PackageTests/Configure/setup.test.hs
- name: "WIN: Install Autotools"
if: runner.os == 'Windows'
shell: ${{ inputs.shell }}
run: |
/usr/bin/pacman --noconfirm -S autotools

- name: Set validate inputs
shell: ${{ inputs.shell }}
run: |
FLAGS="$COMMON_FLAGS"
if [[ "${{ inputs.ghc }}" == "$GHC_FOR_SOLVER_BENCHMARKS" ]]; then
FLAGS="$FLAGS --solver-benchmarks"
fi
if [[ "${{ inputs.ghc }}" == "$GHC_FOR_COMPLETE_HACKAGE_TESTS" ]]; then
FLAGS="$FLAGS --complete-hackage-tests"
fi
echo "FLAGS=$FLAGS" >> "$GITHUB_ENV"

- name: Canonicalize architecture
shell: ${{ inputs.shell }}
run: |
case ${{ runner.arch }} in
X86) arch=i386 ;;
X64) arch=x86_64 ;;
ARM64) arch=aarch64 ;;
*) echo "Unsupported architecture, please fix validate.yaml" 2>/dev/null; exit 1 ;;
esac
echo "CABAL_ARCH=$arch" >> "$GITHUB_ENV"
45 changes: 45 additions & 0 deletions .github/actions/dogfooding/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Dogfooding cabal-install on a ghc/platform
description: Run a cabal-install uncached validate from a previously built binary
inputs:
ghc:
description: ghc version to use
required: true
shell:
description: shell to use
required: false
default: 'bash'
allow-newer:
description: allow-newer line
required: false
constraints:
description: constraints line
required: false

runs:
using: composite
steps:
- uses: ./.github/actions/cabal-setup
with:
ghc: ${{ inputs.ghc }}
shell: ${{ inputs.shell }}
allow-newer: ${{ inputs.allow_newer }}
constraints: ${{ inputs.constraints }}
# We don't use cache to force a build with a fresh store dir and build dir
# This way we check cabal can build all its dependencies
with_cache: 'false'

- name: Download cabal executable from workflow artifacts
uses: actions/download-artifact@v4
with:
name: cabal-${{ runner.os }}-${{ env.CABAL_ARCH }}
path: cabal-head

- name: Untar the cabal executable
shell: ${{ inputs.shell }}
run: |
tar -xzf "./cabal-head/cabal-head-${{ runner.os }}-$CABAL_ARCH.tar.gz" -C cabal-head

- name: Build using cabal HEAD
shell: ${{ inputs.shell }}
run: |
sh validate.sh $COMMON_FLAGS --with-cabal ./cabal-head/cabal -s build
89 changes: 89 additions & 0 deletions .github/actions/validate-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Validate build
description: Build for a full validate on a ghc version
inputs:
ghc:
description: ghc version to use
required: true
allow-newer:
description: allow-newer line
required: false
constraints:
description: constraints line
required: false
static:
description: whether to build statically
required: false
default: 'false'
shell:
description: shell to use
required: false
default: 'bash'
with_cache:
description: whether to instantiate cache
required: false
default: 'true'

runs:
using: composite
steps:
- uses: ./.github/actions/cabal-setup
id: cabal-setup
with:
shell: ${{ inputs.shell }}
ghc: ${{ inputs.ghc }}
allow-newer: ${{ inputs.allow-newer }}
constraints: ${{ inputs.constraints }}
static: ${{ inputs.static }}
with_cache: ${{ inputs.with_cache }}

# The tool is not essential to the rest of the test suite. If
# hackage-repo-tool is not present, any test that requires it will
# be skipped.
# We want to keep this in the loop but we don't want to fail if
# hackage-repo-tool breaks or fails to support a newer GHC version.
- name: Install hackage-repo-tool
continue-on-error: true
shell: ${{ inputs.shell }}
run: |
cabal install --ignore-project hackage-repo-tool
- name: Validate build
shell: ${{ inputs.shell }}
run: |
echo ::group::Build
sh validate.sh $FLAGS -s build
- name: Tar cabal head executable
if: inputs.ghc == env.GHC_FOR_RELEASE
shell: ${{ inputs.shell }}
run: |
echo ::group::Tar
CABAL_EXEC=$(cabal list-bin --builddir=dist-newstyle-validate-ghc-${{ inputs.ghc }} --project-file=cabal.validate.project cabal-install:exe:cabal)
# We have to tar the executable to preserve executable permissions
# see https://github.com/actions/upload-artifact/issues/38
if [[ "${{ runner.os }}" == "Windows" ]]; then
# `cabal list-bin` gives us a windows path but tar needs the posix one
CABAL_EXEC=$(cygpath "$CABAL_EXEC")
fi
if [[ "${{ runner.os }}" == "macOS" ]]; then
# Workaround to avoid bsdtar corrupting the executable
# such that executing it after untar throws `cannot execute binary file`
# see https://github.com/actions/virtual-environments/issues/2619#issuecomment-788397841
sudo /usr/sbin/purge
fi
DIR=$(dirname "$CABAL_EXEC")
FILE=$(basename "$CABAL_EXEC")
CABAL_EXEC_TAR="cabal-head-${{ runner.os }}${{ inputs.static == 'true' && '-static' || '' }}-$CABAL_ARCH.tar.gz"
tar -czvf "$CABAL_EXEC_TAR" -C "$DIR" "$FILE"
echo "CABAL_EXEC_TAR=$CABAL_EXEC_TAR" >> "$GITHUB_ENV"
# We upload the cabal executable built with the ghc used in the release for:
# - Reuse it in the dogfooding job (although we could use the cached build dir)
# - Make it available in the workflow to make easier testing it locally
# (Using the cache in dogfooding would defeat its purpose, though.)
- name: Upload cabal-install executable to workflow artifacts
if: inputs.ghc == env.GHC_FOR_RELEASE
uses: actions/upload-artifact@v4
with:
name: cabal-${{ runner.os }}${{ inputs.static == 'true' && '-static' || '' }}-${{ env.CABAL_ARCH }}
path: ${{ env.CABAL_EXEC_TAR }}
43 changes: 43 additions & 0 deletions .github/actions/validate-old/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Validate old ghcs
description: Run a Cabal-only validate on an older ghc version
inputs:
ghc:
description: ghc version to use
required: true
extra-ghc:
description: old ghc version to test
required: true
shell:
description: shell to use
required: false
default: 'bash'

runs:
using: composite
steps:
- name: Install prerequisites for old GHCs
shell: ${{ inputs.shell }}
run: |
sudo apt-get update
sudo apt-get install libncurses5 libtinfo5
- uses: ./.github/actions/cabal-setup
with:
ghc: ${{ inputs.ghc }}
extra-ghc: ${{ inputs.extra-ghc }}

- name: GHC versions
shell: ${{ inputs.shell }}
run: |
ghc --version
"ghc-${{ inputs.extra-ghc }}" --version
- name: Validate build
shell: ${{ inputs.shell }}
run: |
sh validate.sh $COMMON_FLAGS -s build
- name: "Validate lib-suite-extras --extra-hc ghc-${{ inputs.extra-ghc }}"
shell: ${{ inputs.shell }}
run: |
sh validate.sh $COMMON_FLAGS --lib-only -s lib-suite-extras --extra-hc "ghc-${{ inputs.extra-ghc }}"
15 changes: 15 additions & 0 deletions .github/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# note: GHC_FOR_RELEASE must be an element of GHC_FOR_VALIDATE!
GHC_FOR_RELEASE: "9.4.8"
GHC_FOR_SOLVER_BENCHMARKS: $(GHC_FOR_RELEASE)
GHC_FOR_COMPLETE_HACKAGE_TESTS: $(GHC_FOR_RELEASE)
# these will be decoded with fromJSON, and must be quoted to keep YAML from making objects
# If you remove something from here, then add it to GHC_FOR_VALIDATE_OLD.
# Also a removed GHC from here means that we are actually dropping
# support, so the PR *must* have a changelog entry.
GHC_FOR_VALIDATE: '["9.10.1", "9.8.2", "9.6.6", "9.4.8", "9.2.8", "9.0.2", "8.10.7", "8.8.4"]'
## GHC 7.10.3 does not install on ubuntu-22.04 with ghcup.
## Older GHCs are not supported by ghcup in the first place.
GHC_FOR_VALIDATE_OLD: '["8.4.4", "8.2.2", "8.0.2"]'
#
COMMON_FLAGS: -j 2 -v
LTS_BRANCH: '3.12'
1 change: 1 addition & 0 deletions .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
restore-keys: bootstrap-${{ runner.os }}-${{ matrix.ghc }}-20221115-

- uses: actions/checkout@v4

- uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
Expand Down
Loading
Loading