Skip to content

Commit

Permalink
Workflow for running the test script (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
patritzenfeld authored Jan 29, 2025
1 parent daa2218 commit 2e4ae53
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
100 changes: 100 additions & 0 deletions .github/workflows/test-flex.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
---
name: Compile and Lint Flex-Tasks

env:
tasks: tasks
config: pkgdb-config
script: tasks

on:
push:
branches: ['*']
paths:
- "tasks/*.txt"
- "pkgdb-config/*.yaml"
- ".github/workflows/test-flex.yml"
- "tasks/test.sh"
- "tasks/runGhci.expect"
- "tasks/.hlint.yaml"

permissions: read-all

jobs:
test_flex:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: zsh hlint expect colorized-logs
version: 1.0

- name: Cache DB
id: restore-cache-db
uses: actions/cache@v3
with:
path: ${{ env.tasks }}/root
key: ${{ hashFiles(format('{0}/stack.yaml', env.config)) }}-${{ hashFiles(format('{0}/package.yaml', env.config)) }}
restore-keys: |
${{ hashFiles(format('{0}/stack.yaml', env.config)) }}
- uses: actions/checkout@v4
if: steps.restore-cache-db.outputs.cache-hit != 'true'
with:
repository: fmidue/haskell-template-setup
path: haskell-template-setup

- name: Setup DB
if: steps.restore-cache-db.outputs.cache-hit != 'true'
run: |
set -ex
sudo mv -f ./${{ env.config }}/stack.yaml ./haskell-template-setup
sudo mv -f ./${{ env.config }}/package.yaml ./haskell-template-setup
cd haskell-template-setup
sed -i "s@/autotool/default@$(realpath $PWD/../${{ env.tasks }}/root)@" env
./create.sh
sudo mv root ../${{ env.tasks }}
set +ex
- name: Determine GHC-Version
id: ghc-version
run: |
set -ex
cd ${{ env.tasks }}
ghc_file=$(find root/pkgdb -name "ghci*" -print -quit)
temp="${ghc_file##*/ghci-}"
ghc_version="${temp%-*.conf*}"
echo "version=$ghc_version" >> $GITHUB_OUTPUT
set +ex
- name: Install GHC
uses: haskell-actions/setup@v2
with:
ghc-version: ${{steps.ghc-version.outputs.version}}

- name: Run Test Script
run: |
set -ex
cd ${{ env.tasks }}
find . -name '*.txt' -exec ../${{ env.script }}/test.sh {} root \;
set +ex
- name: Upload artifact
uses: actions/upload-artifact@v4
id: upload-artifact
with:
name: reports
path: ${{ env.tasks }}/*/*.html
if-no-files-found: error
overwrite: true

- name: Link Comment
uses: peter-evans/commit-comment@v3
with:
body: |
Changes in task folder or test-flex workflow. You may review the test results:
[Download Reports](${{ steps.upload-artifact.outputs.artifact-url }})
2 changes: 2 additions & 0 deletions tasks/.hlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
ignore: {name: Redundant pure}
5 changes: 3 additions & 2 deletions tasks/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fi

base_name=$(basename "$1" | sed 's/\(.*\)\..*/\1/')
pkg_path=$PWD/$2/pkgdb
expect_script="$PWD/runGhci.expect"
script_path="$(realpath "$(dirname "$0")")"
expect_script="${script_path}/runGhci.expect"
output_file1="${base_name}/Global.hs"
output_file2="${base_name}/TaskData.hs"
output_file3="${base_name}/Description.hs"
Expand Down Expand Up @@ -63,5 +64,5 @@ expect "$expect_script" "$ghc_version" |
ansi2html >ghc.html

echo -e "${CYAN}writing Hlint report...${NC}"
hlint . --report -q
hlint . --report -q --hint="${script_path}/.hlint.yaml"
echo -e "${CYAN}Done! Check the reports in ghc.html and report.html.${NC}"

1 comment on commit 2e4ae53

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in task folder or test-flex workflow. You may review the test results:

Download Reports

Please sign in to comment.