Skip to content

Commit

Permalink
Merge pull request #1029 from IntersectMBO/mgalazyn/chore/update-nix-…
Browse files Browse the repository at this point in the history
…build-tools

Simplify GHAs using nix, update nix shell haskell tools
  • Loading branch information
carbolymer authored Jan 29, 2025
2 parents e55e28e + c784eb2 commit 9b10c78
Show file tree
Hide file tree
Showing 14 changed files with 153 additions and 191 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/actionlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,13 @@ jobs:
# actionlint is not going to install its own shellcheck.
# This also makes sure that this pipeline runs using
# the same shellcheck as the ones in Nix shells of developers.
- name: Install Nix with good defaults
uses: input-output-hk/install-nix-action@v20
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
substituters = https://cache.iog.io/ https://cache.nixos.org/
nix_path: nixpkgs=channel:nixos-unstable
- uses: cachix/install-nix-action@v18
with:
nix_path: nixpkgs=channel:nixos-unstable
# Make the Nix environment available to next steps
- uses: rrbutani/use-nix-shell-action@v1

- name: Run Actionlint
Expand Down
22 changes: 10 additions & 12 deletions .github/workflows/check-cabal-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Workaround runner image issue
if: runner.os == 'Linux'
# https://github.com/actions/runner-images/issues/7061
run: sudo chown -R "$USER" /usr/local/.ghcup
- uses: actions/checkout@v4

- name: Install Haskell
uses: input-output-hk/setup-haskell@v1
id: setup-haskell
with:
cabal-version: "3.14.1.1"
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
substituters = https://cache.iog.io/ https://cache.nixos.org/
- uses: actions/checkout@v3
- uses: rrbutani/use-nix-shell-action@v1

- name: Cabal check
run: ./scripts/ci/check-cabal-files.sh
- name: Cabal check
run: ./scripts/ci/check-cabal-files.sh
69 changes: 32 additions & 37 deletions .github/workflows/check-cabal-gild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,37 @@ on:
jobs:
check-cabal-gild:
runs-on: ubuntu-latest

env:
CABAL_GILD_VERSION: "1.3.1.2"

steps:
- name: Download cabal-gild
run: |
cabal_gild_path="$(mktemp -d)"
version="${{env.CABAL_GILD_VERSION}}"
curl -sL \
"https://github.com/tfausak/cabal-gild/releases/download/$version/cabal-gild-$version-linux-x64.tar.gz" \
| tar -C "$cabal_gild_path" -xz
echo "PATH=$cabal_gild_path:$PATH" >> "$GITHUB_ENV"
- uses: actions/checkout@v4

- name: Run cabal-gild over all modified files
run: |
rc="0"
echo "cabal-gild version: ${{env.CABAL_GILD_VERSION}}"
for file in $(git ls-files "*.cabal")
do
echo "cabal-gild --mode=check --input=$file"
if ! cabal-gild --mode=check --input="$file"
then
cabal-gild --mode=format --io="$file"
echo "💣 $file is badly formatted. Fix it with:"
echo "cabal-gild --mode=format --io=$file"
echo -e
echo "Diff for $file:"
git diff "$file"
echo -e
rc="1"
fi
done
exit $rc
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
substituters = https://cache.iog.io/ https://cache.nixos.org/
- uses: rrbutani/use-nix-shell-action@v1

- name: Run cabal-gild over all modified files
run: |
rc="0"
echo "cabal-gild version: ${{env.CABAL_GILD_VERSION}}"
for file in $(git ls-files "*.cabal")
do
echo "cabal-gild --mode=check --input=$file"
if ! cabal-gild --mode=check --input="$file"
then
cabal-gild --mode=format --io="$file"
echo "💣 $file is badly formatted. Fix it with:"
echo "cabal-gild --mode=format --io=$file"
echo -e
echo "Diff for $file:"
git diff "$file"
echo -e
rc="1"
fi
done
exit $rc
85 changes: 36 additions & 49 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check Haskell formatting
name: Check Haskell formatting

on:
merge_group:
Expand All @@ -22,62 +22,49 @@ jobs:
check-formatting:
runs-on: ubuntu-latest

env:
FOURMOLU_VERSION: "0.16.2.0"
STYLISH_HASKELL_VERSION: "0.14.6.0"

steps:
- name: Download Fourmolu
run: |
fourmolu_path="$(mktemp -d)"
version="${{env.FOURMOLU_VERSION}}"
curl -sL \
"https://github.com/fourmolu/fourmolu/releases/download/v$version/fourmolu-$version-linux-x86_64" > "$fourmolu_path/fourmolu"
echo "PATH=$fourmolu_path:$PATH" >> "$GITHUB_ENV"
chmod u+rwx "$fourmolu_path/fourmolu"
- uses: actions/checkout@v4

- name: Download stylish-haskell
run: |
stylish_haskell_path="$(mktemp -d)"
version="${{ env.STYLISH_HASKELL_VERSION }}"
curl -sL \
"https://github.com/haskell/stylish-haskell/releases/download/v$version/stylish-haskell-v$version-linux-x86_64.tar.gz" \
| tar -C "$stylish_haskell_path" -xz
echo "PATH=$stylish_haskell_path/stylish-haskell-v$version-linux-x86_64:$PATH" >> "$GITHUB_ENV"
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
substituters = https://cache.iog.io/ https://cache.nixos.org/
- uses: actions/checkout@v3
- uses: rrbutani/use-nix-shell-action@v1

- name: Run formatting over all Haskell files (always succeeds)
run: |
git add .
git stash
- name: Run formatting over all Haskell files (always succeeds)
run: |
git add .
git stash
for x in $(git ls-tree --full-tree --name-only -r HEAD); do
if [ "${x##*.}" == "hs" ]; then
if grep -qE '^#' "$x"; then
echo "$x contains CPP. Skipping."
else
"$(git rev-parse --show-toplevel)/scripts/devshell/prettify" "$x"
for x in $(git ls-tree --full-tree --name-only -r HEAD); do
if [ "${x##*.}" == "hs" ]; then
if grep -qE '^#' "$x"; then
echo "$x contains CPP. Skipping."
else
"$(git rev-parse --show-toplevel)/scripts/devshell/prettify" "$x"
fi
fi
fi
done
done
git --no-pager diff
git --no-pager diff
- name: Run formatting over all modified files
run: |
git add .
git stash
git fetch origin ${{ github.base_ref }} --unshallow
for x in $(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}..HEAD); do
if [ "${x##*.}" == "hs" ]; then
if grep -qE '^#' "$x"; then
echo "$x contains CPP. Skipping."
else
"$(git rev-parse --show-toplevel)/scripts/devshell/prettify" "$x"
- name: Run formatting over all modified files
run: |
git add .
git stash
git fetch origin ${{ github.base_ref }} --unshallow
for x in $(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}..HEAD); do
if [ "${x##*.}" == "hs" ]; then
if grep -qE '^#' "$x"; then
echo "$x contains CPP. Skipping."
else
"$(git rev-parse --show-toplevel)/scripts/devshell/prettify" "$x"
fi
fi
fi
done
done
git --no-pager diff --exit-code
git --no-pager diff --exit-code
2 changes: 1 addition & 1 deletion .github/workflows/check-git-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check git dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-hlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:

steps:

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: haskell-actions/hlint-scan@v1
6 changes: 3 additions & 3 deletions .github/workflows/check-pr-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ jobs:
check-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
if: ${{ github.event_name != 'merge_group' }}
with:
node-version: 16
node-version: 22

- run: npm install [email protected]
if: ${{ github.event_name != 'merge_group' }}
Expand Down
79 changes: 36 additions & 43 deletions .github/workflows/github-page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- master
workflow_dispatch:

jobs:
build:
Expand All @@ -14,54 +15,46 @@ jobs:
shell: bash

steps:
- name: Install Nix
uses: cachix/install-nix-action@v18
with:
# Use last stable nixos channel and the same nix as in channel:
install_url: https://releases.nixos.org/nix/nix-2.11.1/install
nix_path: nixpkgs=channel:nixos-22.11
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
experimental-features = nix-command flakes
allow-import-from-derivation = true
substituters = https://cache.nixos.org https://cache.iog.io
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
- uses: actions/checkout@v4

- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=
substituters = https://cache.iog.io/ https://cache.nixos.org/
- name: Fetch nix cache and update cabal indices
run: |
nix develop .\#haddockShell --command \
- uses: rrbutani/use-nix-shell-action@v1

- name: Update cabal indices
run: |
cabal update
- name: Build whole project
run: |
nix develop .\#haddockShell --command \
- name: Build whole project
run: |
cabal build all
- name: Build documentation
run: |
nix develop .\#haddockShell --command \
- name: Build documentation
run: |
cabal haddock-project --output=./haddocks --internal --foreign-libraries
- name: Compress haddocks
run: |
tar -czf haddocks.tgz -C haddocks .
- name: Upload haddocks artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
continue-on-error: true
with:
name: haddocks
path: ./haddocks.tgz

- name: Deploy documentation to gh-pages 🚀
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN || github.token }}
publish_dir: haddocks
cname: cardano-cli.cardano.intersectmbo.org
force_orphan: true
- name: Compress haddocks
run: |
tar -czf haddocks.tgz -C haddocks .
- name: Upload haddocks artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
continue-on-error: true
with:
name: haddocks
path: ./haddocks.tgz

- name: Deploy documentation to gh-pages 🚀
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN || github.token }}
publish_dir: haddocks
cname: cardano-cli.cardano.intersectmbo.org
force_orphan: true
Loading

0 comments on commit 9b10c78

Please sign in to comment.