Skip to content

Commit

Permalink
ci: Run shfmt and shellcheck (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
sestrella authored Dec 4, 2023
1 parent 15769d5 commit ffd4ce0
Show file tree
Hide file tree
Showing 14 changed files with 75 additions and 287 deletions.
12 changes: 2 additions & 10 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi
source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0="

nix_direnv_watch_file devenv.nix
nix_direnv_watch_file devenv.lock
nix_direnv_watch_file devenv.yaml
if ! use flake . --impure
then
echo "devenv could not be build. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
use devenv
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ concurrency:
cancel-in-progress: true

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
- uses: cachix/cachix-action@v12
with:
name: devenv
- run: nix-env -if https://install.devenv.sh/latest
- run: devenv ci

test:
strategy:
matrix:
Expand All @@ -25,6 +36,7 @@ jobs:
- plugin: stack
fail-fast: true
runs-on: ${{ matrix.os }}
needs: [check]
steps:
- uses: asdf-vm/actions/plugin-test@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
.ghcup/
node_modules/

.devenv.flake.nix
.pre-commit-config.yaml
9 changes: 0 additions & 9 deletions .gitmodules

This file was deleted.

126 changes: 24 additions & 102 deletions flake.lock → devenv.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
{
"nodes": {
"devenv": {
"inputs": {
"flake-compat": "flake-compat",
"nix": "nix",
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1686642933,
"narHash": "sha256-5Z4uitx27QtZIrG9sOSJlZRNcVQn/TI36nj7o70n5Dw=",
"dir": "src/modules",
"lastModified": 1701187605,
"narHash": "sha256-NctguPdUeDVLXFsv6vI1RlEiHLsXkeW3pgZe/mwn1BU=",
"owner": "cachix",
"repo": "devenv",
"rev": "f5278b5d56e39f86a299a2e1889906933a26f762",
"rev": "a7c4dd8f4eb1f98a6b8f04bf08364954e1e73e4f",
"type": "github"
},
"original": {
"dir": "src/modules",
"owner": "cachix",
"repo": "devenv",
"type": "github"
Expand All @@ -38,12 +34,15 @@
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
Expand All @@ -55,7 +54,6 @@
"gitignore": {
"inputs": {
"nixpkgs": [
"devenv",
"pre-commit-hooks",
"nixpkgs"
]
Expand All @@ -74,53 +72,13 @@
"type": "github"
}
},
"lowdown-src": {
"flake": false,
"locked": {
"lastModified": 1633514407,
"narHash": "sha256-Dw32tiMjdK9t3ETl5fzGrutQTzh2rufgZV4A/BbxuD4=",
"owner": "kristapsdz",
"repo": "lowdown",
"rev": "d2c2b44ff6c27b936ec27358a2653caaef8f73b8",
"type": "github"
},
"original": {
"owner": "kristapsdz",
"repo": "lowdown",
"type": "github"
}
},
"nix": {
"inputs": {
"lowdown-src": "lowdown-src",
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-regression": "nixpkgs-regression"
},
"locked": {
"lastModified": 1676545802,
"narHash": "sha256-EK4rZ+Hd5hsvXnzSzk2ikhStJnD63odF7SzsQ8CuSPU=",
"owner": "domenkozar",
"repo": "nix",
"rev": "7c91803598ffbcfe4a55c44ac6d49b2cf07a527f",
"type": "github"
},
"original": {
"owner": "domenkozar",
"ref": "relaxed-flakes",
"repo": "nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1678875422,
"narHash": "sha256-T3o6NcQPwXjxJMn2shz86Chch4ljXgZn746c2caGxd8=",
"lastModified": 1701432845,
"narHash": "sha256-06sd2rQ+DPMSueh+hW4MiXbpMSdhQHJOi/sw0vuwqvs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "126f49a01de5b7e35a43fd43f891ecf6d3a51459",
"rev": "77da99a144cd341408308e0a37622f5edcc6c5ba",
"type": "github"
},
"original": {
Expand All @@ -130,74 +88,38 @@
"type": "github"
}
},
"nixpkgs-regression": {
"locked": {
"lastModified": 1643052045,
"narHash": "sha256-uGJ0VXIhWKGXxkeNnq4TvV3CIOkUJ3PAoLZ3HMzNVMw=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "215d4d0fd80ca5163643b03a33fde804a29cc1e2",
"type": "github"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1678872516,
"narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=",
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1686751072,
"narHash": "sha256-i4TGoVhWiwSkGV8D8Hk8A3MZ68rmAxknEVwTYkE3Wjk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "98be10c950909515f626a776e862c24589fde969",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-22.11",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"flake-compat": "flake-compat",
"flake-utils": "flake-utils",
"gitignore": "gitignore",
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1686050334,
"narHash": "sha256-R0mczWjDzBpIvM3XXhO908X5e2CQqjyh/gFbwZk/7/Q=",
"lastModified": 1700922917,
"narHash": "sha256-ej2fch/T584b5K9sk1UhmZF7W6wEfDHuoUYpFN8dtvM=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "6881eb2ae5d8a3516e34714e7a90d9d95914c4dc",
"rev": "e5ee5c5f3844550c01d2131096c7271cec5e9b78",
"type": "github"
},
"original": {
Expand All @@ -209,8 +131,8 @@
"root": {
"inputs": {
"devenv": "devenv",
"nixpkgs": "nixpkgs_2",
"systems": "systems"
"nixpkgs": "nixpkgs",
"pre-commit-hooks": "pre-commit-hooks"
}
},
"systems": {
Expand Down
10 changes: 10 additions & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{ pkgs, ... }:

{
languages.javascript.enable = true;

pre-commit.hooks = {
shellcheck.enable = true;
shfmt.enable = true;
};
}
3 changes: 3 additions & 0 deletions devenv.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
inputs:
nixpkgs:
url: github:NixOS/nixpkgs/nixpkgs-unstable
36 changes: 0 additions & 36 deletions flake.nix

This file was deleted.

48 changes: 23 additions & 25 deletions lib/utils.bash
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
#!/usr/bin/env bash

asdf_plugin_path() {
echo "$(dirname "$(dirname "$0")")"
dirname "$(dirname "$0")"
}

ghcup_bin_dir() {
echo "$(asdf_plugin_path)/.ghcup/bin"
echo "$(asdf_plugin_path)/.ghcup/bin"
}

ensure_ghcup() {
if ! test -f "$(ghcup_bin_dir)/ghcup"
then
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | env \
BOOTSTRAP_HASKELL_MINIMAL=1 \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
GHCUP_INSTALL_BASE_PREFIX="$(asdf_plugin_path)" \
sh > /dev/null
fi
if ! test -f "$(ghcup_bin_dir)/ghcup"; then
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | env \
BOOTSTRAP_HASKELL_MINIMAL=1 \
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
GHCUP_INSTALL_BASE_PREFIX="$(asdf_plugin_path)" \
sh >/dev/null
fi
}

list_all_versions() {
ensure_ghcup
"$(ghcup_bin_dir)/ghcup" list -t "$1" -r | awk '{printf $2" "}'
ensure_ghcup
"$(ghcup_bin_dir)/ghcup" list -t "$1" -r | awk '{printf $2" "}'
}

ver() {
echo "$1" | awk -F . '{ printf("%02d%02d", $1,$2); }'
echo "$1" | awk -F . '{ printf("%02d%02d", $1,$2); }'
}

install_version() {
local tool="$1"
local version="$2"
local path="$3"

ensure_ghcup

if [[ "$tool" == "ghc" ]] || { [[ "$tool" == "hls" ]] && [[ $(ver "$version") -ge $(ver "1.7") ]]; }
then
"$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "$path"
else
"$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "${path}/bin"
fi
local tool="$1"
local version="$2"
local path="$3"

ensure_ghcup

if [[ $tool == "ghc" ]] || { [[ $tool == "hls" ]] && [[ $(ver "$version") -ge $(ver "1.7") ]]; }; then
"$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "$path"
else
"$(ghcup_bin_dir)/ghcup" install "$tool" "$version" -i "${path}/bin"
fi
}
1 change: 0 additions & 1 deletion test/bats
Submodule bats deleted from e9fd17
Loading

0 comments on commit ffd4ce0

Please sign in to comment.