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

feat: Gno resolver #3

Draft
wants to merge 156 commits into
base: forbid-import-cycle
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
01b0719
copy over from gnoutil pr
thehowl May 26, 2024
232834c
remove util_test
thehowl May 26, 2024
f378217
Merge branch 'master' of github.com:gnolang/gno into dev/morgan/gno-r…
thehowl May 26, 2024
8afeacf
linter fixes
thehowl May 26, 2024
808061d
tmp: gno list
n0izn0iz Oct 7, 2024
2c5d604
tmp
n0izn0iz Oct 7, 2024
dfc0881
tmp: working
n0izn0iz Oct 9, 2024
a35050c
chore: merge remote-tracking branch 'origin/master' into dev/morgan/g…
n0izn0iz Oct 10, 2024
7c7165f
feat: match mapping
n0izn0iz Oct 10, 2024
1c3a830
fix: test and lint
n0izn0iz Oct 10, 2024
f95e4bb
fix: partially fix transpile
n0izn0iz Oct 10, 2024
2d990e5
tmp: support loaded pkgs in test store
n0izn0iz Oct 10, 2024
6995485
tmp: better Module info
n0izn0iz Oct 11, 2024
fb8d518
tmp: follow go resolver logic
n0izn0iz Oct 11, 2024
1c51509
fix: resolver usage in test
n0izn0iz Oct 11, 2024
da65417
chore: mod tidy
n0izn0iz Oct 11, 2024
4a8401a
chore: ignore draft
n0izn0iz Oct 11, 2024
e792771
chore: rename importer -> packages like go, break import cycle and mo…
n0izn0iz Oct 11, 2024
08fbd84
chore: lint and fmt
n0izn0iz Oct 11, 2024
f93a221
Update gnovm/pkg/packages/download.go
n0izn0iz Oct 11, 2024
53c5770
chore: revert merge fails
n0izn0iz Oct 11, 2024
457b0c9
chore: add package and module struct fields comments
n0izn0iz Oct 11, 2024
59a752a
chore: go -> gno
n0izn0iz Oct 11, 2024
e648305
fix: use io instead of os
n0izn0iz Oct 11, 2024
0123512
chore: explicit args
n0izn0iz Oct 11, 2024
d266b8e
chore: improve comment
n0izn0iz Oct 11, 2024
ac435c2
fix: break import cycle
n0izn0iz Oct 21, 2024
178706f
chore: merge remote-tracking branch 'origin/master' into gno-resolver
n0izn0iz Oct 21, 2024
9fbe83c
chore: linter
n0izn0iz Oct 22, 2024
d78fb90
chore: reuse helper
n0izn0iz Oct 22, 2024
f7b6df7
chore: merge remote-tracking branch 'origin/master' into gno-resolver
n0izn0iz Oct 22, 2024
6f2330e
tmp: use gno.work and add back mod files
n0izn0iz Oct 28, 2024
2d9fc96
chore: merge remote-tracking branch 'origin/master' into gno-resolver
n0izn0iz Oct 28, 2024
7c5baf3
chore: Merge branch 'forbid-import-cycle' into gno-resolver
n0izn0iz Jan 7, 2025
b012a33
fix: build
n0izn0iz Jan 7, 2025
c428052
feat: working gno list
n0izn0iz Jan 8, 2025
68b2453
feat: improve
n0izn0iz Jan 8, 2025
fd2917f
chore: remove dev artifact
n0izn0iz Jan 8, 2025
4908939
chore: remove impossible case
n0izn0iz Jan 8, 2025
bb3057e
chore: revert unneeded changes
n0izn0iz Jan 8, 2025
74ebf0c
feat: inject util + consistent naming
n0izn0iz Jan 8, 2025
6c69bed
chore: simplify condition
n0izn0iz Jan 8, 2025
10701c4
chore: explicit log name
n0izn0iz Jan 8, 2025
0e98114
chore: remove dev artifact
n0izn0iz Jan 8, 2025
b6d9007
chore: remove merge fail
n0izn0iz Jan 8, 2025
edba346
chore: remove merge fail
n0izn0iz Jan 8, 2025
78b60ed
chore: remove old pkg loader
n0izn0iz Jan 8, 2025
4104372
chore: node loadconfig
n0izn0iz Jan 8, 2025
0a85338
feat: run gnoland genesis pkg loading in self-contained mode
n0izn0iz Jan 8, 2025
f5b7afc
fix: gnodev tests
n0izn0iz Jan 8, 2025
fba50a7
fix: go fmt and lint
n0izn0iz Jan 8, 2025
5f4610f
Merge branch 'master' into gno-resolver
n0izn0iz Jan 8, 2025
b760e36
fix: gnodev and gnogenesis
n0izn0iz Jan 8, 2025
ceb039b
fix: testing loader paths
n0izn0iz Jan 8, 2025
c7edab0
fix: ignore stdlibs and allow name override
n0izn0iz Jan 8, 2025
82b7ef8
chore: don't override name if not requested
n0izn0iz Jan 8, 2025
9d6b2d8
chore: skip stdlibs and package with no import paths in txs
n0izn0iz Jan 8, 2025
1405da2
chore: fix lint
n0izn0iz Jan 8, 2025
7bb33b2
tmp
n0izn0iz Jan 8, 2025
c95d2bf
fix: linter errors locations
n0izn0iz Jan 8, 2025
6d6ee0d
feat: single file pattern support + misc bugs
n0izn0iz Jan 8, 2025
c5754b5
chore: fmt and lint go
n0izn0iz Jan 8, 2025
a73ba04
fix: don't ignore files without valid package clause
n0izn0iz Jan 8, 2025
cef59f3
fix: mod why
n0izn0iz Jan 8, 2025
b73027b
fix: pass all tests except transpile
n0izn0iz Jan 8, 2025
5b5386f
tmp
n0izn0iz Jan 9, 2025
07375f8
fix: always use relative paths for files in pkgs
n0izn0iz Jan 9, 2025
95963dc
chore: revert transpile changes
n0izn0iz Jan 9, 2025
6f6bb36
chore: Merge branch 'forbid-import-cycle' into gno-resolver
n0izn0iz Jan 9, 2025
1d67048
fix: sort
n0izn0iz Jan 10, 2025
c0eacfb
chore: fix debugger
n0izn0iz Jan 10, 2025
740e3e3
feat: detect stdlibs
n0izn0iz Jan 10, 2025
7523824
chore: Merge remote-tracking branch 'origin/master' into gno-resolver
n0izn0iz Jan 10, 2025
9380f1c
fix: gnodev, gnogensis
n0izn0iz Jan 10, 2025
2f9c35a
chore: lint and fmt
n0izn0iz Jan 10, 2025
85c800a
chore: generate
n0izn0iz Jan 10, 2025
5b06874
test: gnodev
n0izn0iz Jan 10, 2025
3e42e55
tmp
n0izn0iz Jan 17, 2025
fd24486
fix: remove import cycles (#3304)
n0izn0iz Jan 23, 2025
8e1c532
fix(p2p): infinity loop if no peer in queue (#3593)
gfanton Jan 23, 2025
98c4353
test(fuzz): appease goimports by renaming added .go corpus files to *…
odeke-em Jan 24, 2025
f67f186
chore: reorganize gnovm/cmd/gno (#3587)
moul Jan 24, 2025
ad93c33
feat(gnoweb): add gnoconnect html meta entries (#3609)
moul Jan 27, 2025
a885c78
fix(gnovm/softfloat): replace copy.sh with Go generator (#3584)
omarsy Jan 28, 2025
df4113d
feat(examples): update leon's config & home (#3603)
leohhhn Jan 29, 2025
21fe656
feat(r/docs): pager + render paths (#3608)
leohhhn Jan 29, 2025
4d0000e
feat(gnoweb): "No render" page/component (#3611)
leohhhn Jan 29, 2025
533ae67
fix(gnoweb): NoRender response & test (#3634)
leohhhn Jan 29, 2025
15d119f
feat: optimize jitter factor calculation (#3629)
aeddi Jan 29, 2025
b392287
feat: gno mod graph (#3588)
moul Jan 29, 2025
57da324
chore: Trigger CI tests on changes to the main go.mod (#3648)
jefft0 Jan 30, 2025
d3774ce
feat: ownable2step realm (#3594)
0xtekgrinder Jan 31, 2025
5c8dcfd
fix(tm2/pkg/bft/node): make Node.startRPC not leak listeners on any e…
odeke-em Jan 31, 2025
7992a29
feat(tm2/pkg/iavl): add FuzzIterateRange and modernize FuzzMutableTre…
odeke-em Jan 31, 2025
c24f69f
test(tm2/pkg/cmap): add benchmarks to show true impact of contention …
odeke-em Jan 31, 2025
1795fca
chore: Merge remote-tracking branch 'origin/master' into gno-resolver
n0izn0iz Feb 1, 2025
053bfb4
fix: adapt after merge
n0izn0iz Feb 2, 2025
33f90ca
chore: remove merge artifact
n0izn0iz Feb 2, 2025
627eab2
feat(examples/test): quality of life improvements (#3661)
leohhhn Feb 2, 2025
01abd50
chore(examples): modify pausable (#3628)
leohhhn Feb 2, 2025
d5a083b
fix: tests
n0izn0iz Feb 3, 2025
282b818
fix: remove dev artifact
n0izn0iz Feb 3, 2025
723096c
Merge branch 'master' into gno-resolver
n0izn0iz Feb 3, 2025
d35e1ff
fix: revert transpile invocation
n0izn0iz Feb 3, 2025
62f0f9d
fix: include workspace modules in gno test
n0izn0iz Feb 3, 2025
44bff74
chore: revert transpile invocation change
n0izn0iz Feb 3, 2025
8fe26c8
fix: test
n0izn0iz Feb 3, 2025
c6b1f3b
chore: lint
n0izn0iz Feb 3, 2025
315ac5d
chore: remove dev artifact
n0izn0iz Feb 3, 2025
dc0b608
feat(gnoweb): enable strikethrough UI (#3670)
alexiscolin Feb 3, 2025
815cf51
feat: add FOMO3D game implementation (#3344)
stefann-01 Feb 3, 2025
80c68ea
fix: hardcoded dev path in test
n0izn0iz Feb 3, 2025
19e7f5f
fix: mod graph
n0izn0iz Feb 3, 2025
babff8f
chore: miss push
n0izn0iz Feb 3, 2025
4686c7c
fix: allow to ignore stdlibs in sort and sort mempkg files
n0izn0iz Feb 3, 2025
45e8115
Merge branch 'master' into gno-resolver
n0izn0iz Feb 3, 2025
f7d3de8
fix: ignore stdlibs in genesis gen
n0izn0iz Feb 3, 2025
4923559
chore: add todo
n0izn0iz Feb 3, 2025
98ccddd
fix: include other files in pkg
n0izn0iz Feb 3, 2025
52bcc43
fix: include other files in mempkg
n0izn0iz Feb 3, 2025
31b92be
fix: gnodevé
n0izn0iz Feb 3, 2025
df14762
feat: bump max-gas same as current genesis (#3681)
r3v4s Feb 4, 2025
f847090
chore(examples): improve p/moul/txlink (#3682)
moul Feb 4, 2025
85a8740
feat(stdlibs/std)!: replace `IsOriginCall` with `PrevRealm().IsUser()…
omarsy Feb 4, 2025
479b314
feat(gnovm): support constant evaluation of len and cap on arrays (#3…
omarsy Feb 4, 2025
3614b60
fix(github-bot): require most rules to activate when base == `master`…
thehowl Feb 4, 2025
8410060
feat: add r/moul/present (#3668)
moul Feb 4, 2025
6fe3b31
chore(pipeline): run build of github pages on pullRequests (#3607)
Villaquiranm Feb 4, 2025
d75f1a2
fix(docs/gnokey): addpkg subcommand documentation (#3635)
Nemanya8 Feb 4, 2025
d7bfee2
feat(mux): add wildcard (*) for more flexible route matching (#3631)
mous1985 Feb 5, 2025
e12b3f1
feat: add JJOptimist's Homepage realm to examples (#3405)
JJOptimist Feb 5, 2025
9e6a67b
fix(p2p): Avoid inifinty loop during transport/listener `Accept` (#3662)
gfanton Feb 5, 2025
0b76b0b
feat(cmd/gno): add gno version command (#3002)
kazai777 Feb 5, 2025
0bc4423
fix(gnoweb): escape bash chars in help args (#3672)
alexiscolin Feb 6, 2025
7e1f5b5
fix(cmd/gno): only perform preprocessing in lint (#3597)
thehowl Feb 6, 2025
dd0360d
chore: remove govdao dependency in `r/gov/dao/bridge` (#3523)
leohhhn Feb 6, 2025
37ab807
test(cmd/gnoland): add test to ensure to not import tests/stdlibs (#3…
thehowl Feb 6, 2025
a01a030
chore: make codecov only care about newlines (#3277)
moul Feb 6, 2025
08d29a5
feat(gnoweb): display network info (#3679)
alexiscolin Feb 6, 2025
29c3ee6
chore(examples): change AVL pager to expect a read only tree (#3673)
jeronimoalbi Feb 6, 2025
ce6a4aa
fix(gnovm): correct filetest directive behavior (#3697)
ltzmaxwell Feb 6, 2025
dcd3834
feat(examples): Implement markdown package (#2912)
sunspirit99 Feb 6, 2025
de4a405
fix(rpc): always return array reponses for batch requests (#3678)
omarsy Feb 6, 2025
47395b1
fix: utilize `p2p.ExternalAddress` properly for dialing (#3581)
zivkovicmilos Feb 7, 2025
6367a3e
feat: add support for validating tx signatures in `gnogenesis` (#3690)
zivkovicmilos Feb 7, 2025
4f91841
fix(gnoweb): header links with webquery (#3671)
alexiscolin Feb 7, 2025
b4ebf6c
feat(examples): add p/moul/cow (#3325)
moul Feb 7, 2025
f75a77a
chore(examples): add microposts example (#3660)
moul Feb 7, 2025
c41a056
fix: skip failed txs in Portal Loop reset (#3699)
zivkovicmilos Feb 7, 2025
be61d7d
perf(tm2/pkg/amino): reduce RAM heavy-handedness by *bytes.Buffer poo…
odeke-em Feb 7, 2025
c93c225
chore: Merge remote-tracking branch 'origin/master' into gno-resolver
n0izn0iz Feb 8, 2025
568836c
chore: remove 'SelfContained'
n0izn0iz Feb 8, 2025
847f325
chore: add testdata
n0izn0iz Feb 8, 2025
a673ecc
chore: rm uneeded instance
n0izn0iz Feb 9, 2025
e07af66
chore: revert uneeded change
n0izn0iz Feb 9, 2025
6735ef4
chore: add tests and cut uneeded features
n0izn0iz Feb 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 3 additions & 12 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,10 @@ coverage:
round: down
precision: 2
status:
project:
patch: # new lines
default:
target: auto
threshold: 5 # Let's decrease this later.
base: parent
if_no_uploads: error
if_not_found: success
if_ci_failed: error
only_pulls: false
patch:
default:
target: auto
threshold: 5 # Let's decrease this later.
target: 80
threshold: 10
base: auto
if_no_uploads: error
if_not_found: success
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ jobs:
define-prs-matrix:
name: Define PRs matrix
# Skip this workflow if:
# - the bot is not configured on this repo/fork
# - the bot is retriggering itself
# - the event is emitted by codecov
# - the event is a review on a pull request from a fork (see save-pr-number job below)
if: |
vars.GH_BOT_LOGIN != '' &&
github.actor != vars.GH_BOT_LOGIN &&
github.actor != 'codecov[bot]' &&
(github.event_name != 'pull_request_review' || github.event.pull_request.base.repo.full_name == github.event.pull_request.head.repo.full_name)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
go-version: ${{ matrix.goversion }}
- run: go install -v ./gnovm/cmd/gno
- run: go run ./gnovm/cmd/gno transpile -v --gobuild ./examples
- run: go run ./gnovm/cmd/gno tool transpile -v --gobuild ./examples
test:
strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/genesis-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
testnet: [ "test5.gno.land" ]
testnet: [ ] # Currently, all active testnet deployment genesis.json are legacy
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# generate Go docs and publish on gh-pages branch
# Live at: https://gnolang.github.io/gno
name: Go Reference Docs Deployment
name: GitHub pages (godoc & stdlib_diff) build and deploy

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

permissions:
Expand All @@ -19,29 +22,39 @@ concurrency:

jobs:
build:
if: ${{ github.repository == 'gnolang/gno' }} # Alternatively, validate based on provided tokens and permissions.
if: github.repository == 'gnolang/gno' # Alternatively, validate based on provided tokens and permissions.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: echo "GOROOT=$(go env GOROOT)" >> $GITHUB_ENV
- run: echo $GOROOT
# Use the goroot at the top of the project to compare with the GnoVM
# stdlib, rather than the one in stdlib_diff (which may have a go.mod with
# a different toolchain version).
- run: echo "GOROOT_SAVE=$(go env GOROOT)" >> $GITHUB_ENV
- run: "cd misc/stdlib_diff && make gen"
- run: "cd misc/gendocs && make install gen"
- run: "mkdir -p pages_output/stdlib_diff"
- run: |
cp -r misc/gendocs/godoc/* pages_output/
cp -r misc/stdlib_diff/stdlib_diff/* pages_output/stdlib_diff/

# These two last steps will be skipped on pull requests
- uses: actions/configure-pages@v5
id: pages
if: github.event_name != 'pull_request'

- uses: actions/upload-pages-artifact@v3
if: github.event_name != 'pull_request'
with:
path: ./pages_output

deploy:
if: ${{ github.repository == 'gnolang/gno' }} # Alternatively, validate based on provided tokens and permissions.
if: >
github.repository == 'gnolang/gno' &&
github.ref == 'refs/heads/master' &&
github.event_name == 'push'
runs-on: ubuntu-latest
environment:
name: github-pages
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/gnoland.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ on:
# since there are integration suites that cover the gnovm / tm2
- gnovm/**
- tm2/**
# Changes to examples/ can create failures in gno.land, eg. txtars,
# see: https://github.com/gnolang/gno/pull/3590
- examples/**
# We trigger the testing workflow for changes to the main go.mod,
# since this can affect test results
- go.mod
workflow_dispatch:

jobs:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/gnovm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
paths:
- gnovm/**
- tm2/** # GnoVM has a dependency on TM2 types
# We trigger the testing workflow for changes to the main go.mod,
# since this can affect test results
- go.mod
workflow_dispatch:

jobs:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/releaser-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
- master
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}

permissions:
contents: write # needed to write releases
id-token: write # needed for keyless signing
Expand All @@ -27,7 +30,7 @@ jobs:
cache: true

- uses: sigstore/cosign-installer@v3.7.0
- uses: anchore/sbom-action/download-syft@v0.17.8
- uses: anchore/sbom-action/download-syft@v0.17.9

- uses: docker/login-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releaser-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
cache: true

- uses: sigstore/cosign-installer@v3.7.0
- uses: anchore/sbom-action/download-syft@v0.17.8
- uses: anchore/sbom-action/download-syft@v0.17.9

- uses: docker/login-action@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tm2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
pull_request:
paths:
- tm2/**
# We trigger the testing workflow for changes to the main go.mod,
# since this can affect test results
- go.mod
workflow_dispatch:

jobs:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ coverage.out
*.swp
*.swo
*.bak

.tmp/
wal/
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Additionally, it's not possible to use `gofumpt` for code formatting with

(flycheck-define-checker gno-lint
"A GNO syntax checker using the gno lint tool."
:command ("gno" "lint" source-original)
:command ("gno" "tool" "lint" source-original)
:error-patterns (;; ./file.gno:32: error message (code=1)
(error line-start (file-name) ":" line ": " (message) " (code=" (id (one-or-more digit)) ")." line-end))
;; Ensure the file is saved, to work around
Expand Down
16 changes: 16 additions & 0 deletions contribs/github-bot/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
GNOROOT_DIR ?= $(abspath $(lastword $(MAKEFILE_LIST))/../../../)

rundep := go run -modfile ../../misc/devdeps/go.mod
golangci_lint := $(rundep) github.com/golangci/golangci-lint/cmd/golangci-lint

.PHONY: install
install:
go install .

.PHONY: lint
lint:
$(golangci_lint) --config ../../.github/golangci.yml run ./...

.PHONY: test
test:
go test $(GOTEST_FLAGS) -v ./...
10 changes: 5 additions & 5 deletions contribs/github-bot/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/gnolang/gno/contribs/github-bot

go 1.22
go 1.22.0

toolchain go1.22.2
toolchain go1.23.2

replace github.com/gnolang/gno => ../..

Expand All @@ -11,7 +11,7 @@ require (
github.com/google/go-github/v64 v64.0.0
github.com/migueleliasweb/go-github-mock v1.0.1
github.com/sethvargo/go-githubactions v1.3.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/xlab/treeprint v1.2.0
)

Expand All @@ -21,8 +21,8 @@ require (
github.com/gorilla/mux v1.8.1 // indirect
github.com/peterbourgon/ff/v3 v3.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/term v0.28.0 // indirect
golang.org/x/time v0.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
12 changes: 6 additions & 6 deletions contribs/github-bot/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contribs/github-bot/internal/check/comment.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.

##### 📚 Resources:
- [Report a bug with the bot](https://github.com/gnolang/gno/issues/3238).
- [Report a bug with the bot](https://www.github.com/gnolang/gno/issues/3238).
- [View the bot’s configuration file](https://github.com/gnolang/gno/tree/master/contribs/github-bot/internal/config/config.go).

{{ if or .AutoRules .ManualRules }}<details><summary><b>Debug</b></summary><blockquote>
Expand Down
21 changes: 21 additions & 0 deletions contribs/github-bot/internal/conditions/author.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,24 @@ func (a *authorInTeam) IsMet(pr *github.PullRequest, details treeprint.Tree) boo
func AuthorInTeam(gh *client.GitHub, team string) Condition {
return &authorInTeam{gh: gh, team: team}
}

type authorAssociationIs struct {
assoc string
}

var _ Condition = &authorAssociationIs{}

func (a *authorAssociationIs) IsMet(pr *github.PullRequest, details treeprint.Tree) bool {
detail := fmt.Sprintf("Pull request author has author_association: %q", a.assoc)

return utils.AddStatusNode(pr.GetAuthorAssociation() == a.assoc, detail, details)
}

// AuthorAssociationIs asserts that the author of the PR has the given value for
// the GitHub "author association" field, on the PR.
//
// See https://docs.github.com/en/graphql/reference/enums#commentauthorassociation
// for a list of possible values and descriptions.
func AuthorAssociationIs(association string) Condition {
return &authorAssociationIs{assoc: association}
}
27 changes: 27 additions & 0 deletions contribs/github-bot/internal/conditions/author_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,30 @@ func TestAuthorInTeam(t *testing.T) {
})
}
}

func TestAuthorAssociationIs(t *testing.T) {
t.Parallel()

for _, testCase := range []struct {
name string
association string
associationWant string
isMet bool
}{
{"has", "MEMBER", "MEMBER", true},
{"hasNot", "COLLABORATOR", "MEMBER", false},
} {
t.Run(testCase.name, func(t *testing.T) {
t.Parallel()

pr := &github.PullRequest{
AuthorAssociation: github.String(testCase.association),
}
details := treeprint.New()
condition := AuthorAssociationIs(testCase.associationWant)

assert.Equal(t, condition.IsMet(pr, details), testCase.isMet, fmt.Sprintf("condition should have a met status: %t", testCase.isMet))
assert.True(t, utils.TestLastNodeStatus(t, testCase.isMet, details), fmt.Sprintf("condition details should have a status: %t", testCase.isMet))
})
}
}
2 changes: 1 addition & 1 deletion contribs/github-bot/internal/conditions/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// Draft Condition.
type draft struct{}

var _ Condition = &baseBranch{}
var _ Condition = &draft{}

func (*draft) IsMet(pr *github.PullRequest, details treeprint.Tree) bool {
return utils.AddStatusNode(pr.GetDraft(), "This pull request is a draft", details)
Expand Down
Loading