Skip to content

Commit

Permalink
start building out github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
shayne-fletcher committed Jan 28, 2024
1 parent fa89fe3 commit 083d56b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 28 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/hlint-from-scratch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ jobs:
os: [ubuntu, macos, windows]
steps:
- uses: actions/checkout@v4
- run: stack upgrade
- run: brew install automake
if: matrix.os == 'macos'
- run: cabal update
# - run: cabal new-install cabal-install --overwrite-policy=always
- run: cabal new-install apply-refact
if: matrix.os == 'ubuntu'
- run: |-
echo "GHCLIB_AZURE='1'" >> $GITHUB_ENV
echo "repo_dir=$(mktemp -d)" >> $GITHUB_ENV
echo "repo_dir=." >> $GITHUB_ENV
shell: bash
- run: ./hlint-from-scratch.sh --init="$repo_dir"
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `hlint-from-scratch`
# `hlint-from-scratch` [![hlint-from-scratch](https://github.com/shayne-fletcher/hlint-from-scratch/actions/workflows/hlint-from-scratch.yml/badge.svg)](https://github.com/shayne-fletcher/hlint-from-scratch/actions/workflows/hlint-from-scratch.yml)

Scripts for building HLint from GHC `HEAD` (and other flavors).

Expand Down
17 changes: 9 additions & 8 deletions hlint-from-scratch-cabal-build-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ opts:
"
usage="usage: $prog ARGS"

ghc_version=""
ghc_version="$(ghc --version | sed -e 's/The Glorious Glasgow Haskell Compilation System, version //g' -e 's/^/ghc-/g')"
version_tag=""
ghc_lib_dir=""
ghc_lib_parser_ex_dir=""
Expand Down Expand Up @@ -84,17 +84,18 @@ done

set -u

[ ! -f "$HOME/$ghc_version/bin/ghc" ] && { echo "$HOME/$ghc_version/bin/ghc not found" && exit 1; }
PATH="$HOME/$ghc_version/bin:$PATH"
export PATH
if [ -d "$HOME/$ghc_version" ]; then
PATH="$HOME/$ghc_version/bin:$PATH"
export PATH
fi

# Make sure cabal-install is up-to-date with the most recent
# available. At this time there aren't build plans for compilers >
# ghc-9.2.4.
(PATH=$HOME/ghc-9.2.4/bin:$PATH; export PATH && \
cabal update && \
cabal new-install cabal-install --overwrite-policy=always \
)
# (PATH=$HOME/ghc-9.2.4/bin:$PATH; export PATH && \
# cabal update && \
# cabal new-install cabal-install --overwrite-policy=always \
# )

echo "cabal-install: $(which cabal)"
echo "cabal-install version: $(cabal -V)"
Expand Down
49 changes: 32 additions & 17 deletions hlint-from-scratch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ while [ $# -gt 0 ]; do
elif [[ "$1" =~ --ghc-flavor=([^[:space:]]*) ]]; then
GHC_FLAVOR="${BASH_REMATCH[1]}"
elif [[ "$1" =~ --init=([^[:space:]]+) ]]; then
init_arg="${BASH_REMATCH[1]}"
./hlint-from-scratch-init.sh --repo-dir="$init_arg"
repo_dir="${BASH_REMATCH[1]}"
./hlint-from-scratch-init.sh --repo-dir="$repo-dir"
echo "repo-dir \"$repo_dir\" initialized"
echo "next: hlint-from-scratch --ghc-flavor=... ... --repo-dir=$repo_dir"
exit 0
Expand Down Expand Up @@ -234,9 +234,9 @@ if [ -z "$GHC_FLAVOR" ]; then
else
eval "$cmd" "$GHC_FLAVOR"
fi
sha_ghc_lib_parser=$(shasum -a 256 "$repo_dir"/ghc-lib/ghc-lib-parser-"$version".tar.gz | awk '{ print $1 }')
#sha_ghc_lib_parser=$(shasum -a 256 "$repo_dir"/ghc-lib/ghc-lib-parser-"$version".tar.gz | awk '{ print $1 }')

# temp disable while i focus on minimal set of github actions
# temp disabled while i focus on minimal set of github actions
if false; then
if [ -z "$GHC_FLAVOR" ]; then
# If the above worked out, update CI.hs.
Expand Down Expand Up @@ -305,16 +305,14 @@ $allow_newer\n\
# --\n\
extra-deps:\n\
# ghc-lib-parser\n\
- archive: ${repo_dir}/ghc-lib/ghc-lib-parser-${version}.tar.gz\n\
sha256: \"${sha_ghc_lib_parser}\";\
- archive: ${repo_dir}/ghc-lib/ghc-lib-parser-${version}.tar.gz;\
g" | \
sed -e "s;^resolver:.*$;resolver: ${resolver};g" > stack-head.yaml
else
cat > stack-head.yaml <<EOF
resolver: $resolver
extra-deps:
- archive: ${repo_dir}/ghc-lib/ghc-lib-parser-$version.tar.gz
sha256: "$sha_ghc_lib_parser"
ghc-options:
"$DOLLAR$everything": -j
"$DOLLAR$locals": -ddump-to-file -ddump-hi -Wall -Wno-name-shadowing -Wunused-imports
Expand All @@ -333,8 +331,11 @@ stack_yaml=stack-head.yaml
stack_yaml_flag="--stack-yaml $stack_yaml"
# No need to pass $resolver_flag here, we fixed the resolver in
# 'stack-head.yaml'.
set +e
cat "$stack_yaml"
eval "$runhaskell $stack_yaml_flag CI.hs -- $no_builds $stack_yaml_flag --version-tag $version"
sha_ghc_lib_parser_ex=$(shasum -a 256 "$repo_dir"/ghc-lib-parser-ex/ghc-lib-parser-ex-"$version".tar.gz | awk '{ print $1 }')
# sha_ghc_lib_parser_ex=$(shasum -a 256 "$repo_dir"/ghc-lib-parser-ex/ghc-lib-parser-ex-"$version".tar.gz | awk '{ print $1 }')
set -e

# Hlint

Expand Down Expand Up @@ -376,9 +377,7 @@ packages:
- .
extra-deps:
- archive: $repo_dir/ghc-lib/ghc-lib-parser-$version.tar.gz
sha256: "$sha_ghc_lib_parser"
- archive: $repo_dir/ghc-lib-parser-ex/ghc-lib-parser-ex-$version.tar.gz
sha256: "$sha_ghc_lib_parser_ex"
ghc-options:
"$DOLLAR$everything": -j
"$DOLLAR$locals": -ddump-to-file -ddump-hi -Werror=unused-imports -Werror=unused-local-binds -Werror=unused-top-binds -Werror=orphans
Expand All @@ -400,17 +399,34 @@ if ! [ "$no_builds" == --no-builds ]; then
# Again, wrong to pass $resolver_flag here.

# Build hlint.
eval "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" "stack" "$stack_yaml_flag" "build"
if [ $(uname) == 'Darwin' ]; then
eval "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" "stack" "$stack_yaml_flag" "build"
else
eval "stack" "$stack_yaml_flag" "build"
fi

# Run its tests.
eval "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" "stack" "$stack_yaml_flag" "run" "--" "--test"
if [ $(uname) == 'Darwin' ]; then
eval "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" "stack" "$stack_yaml_flag" "run" "--" "--test"
else
eval "stack" "$stack_yaml_flag" "run" "--" "--test"
fi

# Test there are no changes to 'hints.md'.
eval "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" "stack" "$stack_yaml_flag" "run" "--" "hlint" "--generate-summary"
if [ $(uname) == 'Darwin' ]; then
eval "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" "stack" "$stack_yaml_flag" "run" "--" "hlint" "--generate-summary"
else
eval "stack" "$stack_yaml_flag" "run" "--" "hlint" "--generate-summary"
fi

git diff --exit-code hints.md

# Run it on its own source.
eval "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" "stack" "$stack_yaml_flag" "run" "--" "src"
if [ $(uname) == 'Darwin' ]; then
eval "C_INCLUDE_PATH=$(xcrun --show-sdk-path)/usr/include/ffi" "stack" "$stack_yaml_flag" "run" "--" "src"
else
eval "stack" "$stack_yaml_flag" "run" "--" "src"
fi
fi

# --
Expand Down Expand Up @@ -445,9 +461,8 @@ eval "stack" "$stack_yaml_flag" "sdist" "." "--tar-dir" "."
# - Depending on the contents of `$with_haddock_flag`. Also,
# - Run ghc-lib-test-mini-hlint, ghc-lib-test-mini-compile and the
# hlint test suite.
tmp_dir="$HOME/tmp"
mkdir -p "$tmp_dir"
(cd "$HOME"/tmp && hlint-from-scratch-cabal-build-test.sh \
tmp_dir=$(mktemp -d)
(cd "$tmp_dir" && hlint-from-scratch-cabal-build-test.sh \
"$cabal_with_ghc_flag" \
--version-tag="$version" \
--ghc-lib-dir="$repo_dir/ghc-lib" \
Expand Down

0 comments on commit 083d56b

Please sign in to comment.