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 e656b55
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/hlint-from-scratch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@ 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
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
37 changes: 25 additions & 12 deletions hlint-from-scratch.sh
Original file line number Diff line number Diff line change
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 @@ -334,7 +332,7 @@ stack_yaml_flag="--stack-yaml $stack_yaml"
# No need to pass $resolver_flag here, we fixed the resolver in
# 'stack-head.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 }')

# Hlint

Expand Down Expand Up @@ -376,9 +374,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 +396,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

0 comments on commit e656b55

Please sign in to comment.