forked from alpha-omega-labs/genesis-crypto
-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (105 loc) · 3.83 KB
/
lint.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Run Lint
# Lint runs golangci-lint over the entire cronos repository This workflow is
# run on every pull request and push to main The `golangci` will pass without
# running if no *.{go, mod, sum} files have been changed.
on:
pull_request:
push:
branches:
- main
- release/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
golangci:
name: Run golangci-lint
runs-on: ubuntu-latest
timeout-minutes: 40
steps:
- uses: actions/setup-go@v3
with:
go-version: '^1.20.0'
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
# pin to nix-2.13 to workaround compability issue of 2.14,
# see: https://github.com/cachix/install-nix-action/issues/161
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
**/*.go
*.mod
*.sum
- name: run golangci-lint
run: |
nix profile install nixpkgs#golangci-lint
nix profile install -f ./nix rocksdb
export PKG_CONFIG_PATH=$HOME/.nix-profile/lib/pkgconfig
export CGO_CFLAGS="$(pkg-config --cflags rocksdb)" CGO_LDFLAGS="$(pkg-config --libs rocksdb)"
golangci-lint version
BUILD_TAGS=rocksdb,grocksdb_clean_link
echo "go build"
go build -tags $BUILD_TAGS ./cmd/cronosd
echo "golangci-lint ."
golangci-lint run --out-format=github-actions --path-prefix=./ --timeout 10m --build-tags $BUILD_TAGS
# Check only if there are differences in the source code
if: steps.changed-files.outputs.any_changed == 'true'
lint-python:
name: Lint python
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
**/poetry.lock
**/pyproject.toml
**/*.py
- uses: cachix/install-nix-action@v22
with:
# pin to nix-2.13 to workaround compability issue of 2.14,
# see: https://github.com/cachix/install-nix-action/issues/161
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
if: steps.changed-files.outputs.any_changed == 'true'
- uses: cachix/cachix-action@v12
if: steps.changed-files.outputs.any_changed == 'true'
with:
name: cronos
- run: nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py"
if: steps.changed-files.outputs.any_changed == 'true'
lint-nix:
name: Lint nix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- id: changed-files
uses: tj-actions/changed-files@v34
with:
files: |
*.nix
**/*.nix
- uses: cachix/install-nix-action@v22
with:
# pin to nix-2.13 to workaround compability issue of 2.14,
# see: https://github.com/cachix/install-nix-action/issues/161
install_url: https://releases.nixos.org/nix/nix-2.13.3/install
nix_path: nixpkgs=channel:nixos-22.11
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
if: steps.changed-files.outputs.any_changed == 'true'
- run: nix-shell -I nixpkgs=./nix -p nixpkgs-fmt --run "make lint-nix"
if: steps.changed-files.outputs.any_changed == 'true'