Skip to content

Commit

Permalink
fix: integration tests are not run in CI (evmos#1221)
Browse files Browse the repository at this point in the history
Solution:
- make it run
- add python linter job for the python codes
- fix nix expression to build ethermintd

add file diff condition

add gomod2nix check
  • Loading branch information
yihuang committed Aug 2, 2022
1 parent a902c8a commit 0e46b15
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 87 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 88
extend-ignore = E203
exclude = .git,__pycache__,node_modules,.direnv
29 changes: 29 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,32 @@ jobs:
- uses: articulate/actions-markdownlint@v1.1.0
# Check only if there are differences in the source code
if: env.GIT_DIFF
python-lint:
name: Run flake8 on python integration tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: cachix/install-nix-action@v15
- uses: cachix/cachix-action@v10
with:
name: ethermint
- uses: technote-space/get-diff-action@v6.1.0
with:
PATTERNS: |
**/**.py
- run: |
nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py"
if: env.GIT_DIFF
gomod2nix:
name: Check gomod2nix.toml file is up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.3.4
- uses: cachix/install-nix-action@v15
- uses: cachix/cachix-action@v10
with:
name: ethermint
- name: run gomod2nix
run: |
nix run -f ./nix gomod2nix
git diff --no-ext-diff --exit-code
10 changes: 9 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ jobs:
with:
name: ethermint
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
- uses: technote-space/get-diff-action@v6.1.0
with:
PATTERNS: |
**/**.sol
**/**.go
go.mod
go.sum
tests/integration_tests/**
- name: Run integration tests
run: make run-integration-tests
if: env.GIT_DIFF
Expand Down Expand Up @@ -202,4 +210,4 @@ jobs:
- name: Test simulation after import
run: |
make test-sim-after-import
if: env.GIT_DIFF
if: env.GIT_DIFF
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,16 @@ lint:
@@test -n "$$golangci-lint version | awk '$4 >= 1.42')"
golangci-lint run --out-format=tab -n

lint-py:
flake8 --show-source --count --statistics \
--format="::error file=%(path)s,line=%(row)d,col=%(col)d::%(path)s:%(row)d:%(col)d: %(code)s %(text)s" \

format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs gofumpt -d -e -extra

lint-fix:
golangci-lint run --fix --out-format=tab --issues-exit-code=0
.PHONY: lint lint-fix
.PHONY: lint lint-fix lint-py

format-fix:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "./client/docs/statik/statik.go" -not -name '*.pb.go' -not -name '*.pb.gw.go' | xargs gofumpt -w -s
Expand Down
20 changes: 4 additions & 16 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{ lib
, buildGoApplication
, nix-gitignore
, rev ? "dirty"
}:
let
Expand All @@ -17,21 +16,10 @@ let
in
buildGoApplication rec {
inherit pname version tags ldflags;
src = (nix-gitignore.gitignoreSourcePure [
"../*" # ignore all, then add whitelists
"!../x/"
"!../app/"
"!../cmd/"
"!../client/"
"!../server/"
"!../crypto/"
"!../rpc/"
"!../types/"
"!../encoding/"
"!../go.mod"
"!../go.sum"
"!../gomod2nix.toml"
] ./.);
src = lib.sourceByRegex ./. [
"^(x|app|cmd|client|server|crypto|rpc|types|encoding|ethereum|testutil|version|go.mod|go.sum|gomod2nix.toml)($|/.*)"
"^tests(/.*[.]go)?$"
];
modules = ./gomod2nix.toml;
doCheck = false;
pwd = src; # needed to support replace
Expand Down
Loading

0 comments on commit 0e46b15

Please sign in to comment.