Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use submodule nph in CI to check lint #2988

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:

export MAKEFLAGS="-j1"
export NIMFLAGS="--colors:off -d:chronicles_colors:none"

make V=1 LOG_LEVEL=DEBUG QUICK_AND_DIRTY_COMPILER=1 POSTGRES=$postgres_enabled test testwakunode2

build-docker-image:
Expand All @@ -141,25 +141,36 @@ jobs:
nim_wakunode_image: ${{ needs.build-docker-image.outputs.image }}
test_type: node-optional
debug: waku*

lint:
name: "Lint"
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v3

- name: Get submodules hash
id: submodules
run: |
echo "hash=$(git submodule status | awk '{print $1}' | sort | shasum -a 256 | sed 's/[ -]*//g')" >> $GITHUB_OUTPUT

- name: Cache submodules
uses: actions/cache@v3
with:
fetch-depth: 2 # In PR, has extra merge commit: ^1 = PR, ^2 = base
path: |
vendor/
.git/modules
key: ${{ runner.os }}-vendor-modules-${{ steps.submodules.outputs.hash }}

- name: Build nph
run: |
make build-nph

- name: Check nph formatting
# Pin nph to a specific version to avoid sudden style differences.
# Updating nph version should be accompanied with running the new
# version on the fluffy directory.
run: |
VERSION="v0.5.1"
ARCHIVE="nph-linux_x64.tar.gz"
curl -L "https://github.com/arnetheduck/nph/releases/download/${VERSION}/${ARCHIVE}" -o ${ARCHIVE}
tar -xzf ${ARCHIVE}
shopt -s extglob # Enable extended globbing
./nph examples waku tests tools apps *.@(nim|nims|nimble)
NPH=$(make print-nph-path)
echo "using nph at ${NPH}"
"${NPH}" examples waku tests tools apps *.@(nim|nims|nimble)
git diff --exit-code
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,28 @@ networkmonitor: | build deps librln
############
## Format ##
############
.PHONY: build-nph clean-nph install-nph
.PHONY: set-nim-202 build-nph install-nph clean-nph print-nph-path

set-nim-202:
ifneq ($(shell nim --version|grep "2\.0\.2" -c), "1")
ifeq ($(detected_OS),Linux)
wget https://nim-lang.org/download/nim-2.0.2-linux_x64.tar.xz -O nim-2.0.2-linux_x64.tar.xz
echo "3f1aaf4e19b2c341afad7b0f29644d6a40aebb71c7c02420489595751b1796ee66b4a3ba7783c504ef5d732b45e9f0d5443576580c3652e820ce3aebee768f93 nim-2.0.2-linux_x64.tar.xz" > nim-2.0.2-linux_x64.tar.xz.sha512
sha512sum -c nim-2.0.2-linux_x64.tar.xz.sha512
tar xaf nim-2.0.2-linux_x64.tar.xz
NIM_202 := "./nim-2.0.2/bin/nim"
else
echo "Please compile nph manually or improve this job"
exit 1
endif
else
NIM_202 := $(shell which nim)
endif

build-nph:
build-nph: set-nim-202
ifeq ("$(wildcard $(NPH))","")
$(ENV_SCRIPT) nim c vendor/nph/src/nph.nim
echo -e $(BUILD_MSG) "nph with $(NIM_202)" && \
$(ENV_SCRIPT) $(NIM_202) c vendor/nph/src/nph.nim
endif

GIT_PRE_COMMIT_HOOK := .git/hooks/pre-commit
Expand All @@ -294,6 +311,10 @@ nph/%: build-nph
clean-nph:
rm -f $(NPH)

# To avoid hardcoding nph binary location in several places
print-nph-path:
echo "$(NPH)"

clean: | clean-nph

###################
Expand Down
Loading