Skip to content

Commit

Permalink
Merge branch 'main' into sevey/timeout-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MSevey committed May 30, 2024
2 parents 5236cc6 + 994378c commit 4fb750f
Show file tree
Hide file tree
Showing 36 changed files with 281 additions and 106 deletions.
21 changes: 4 additions & 17 deletions .github/workflows/housekeeping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ on:
types: [opened, ready_for_review]

jobs:
issue-management:
if: ${{ github.event.issue }}
name: Add issues to project and add triage label
add-to-project-with-knuu-label:
# ignore dependabot PRs
if: ${{ github.actor != 'dependabot[bot]' }}
name: Add issues and PRs to project and add knuu label
uses: celestiaorg/.github/.github/workflows/[email protected]
secrets: inherit
permissions:
Expand All @@ -21,20 +22,6 @@ jobs:
run-projects: true
project-url: https://github.com/orgs/celestiaorg/projects/27

add-pr-to-project:
# ignore dependabot PRs
if: ${{ github.event.pull_request && github.actor != 'dependabot[bot]' }}
name: Add PRs to project
uses: celestiaorg/.github/.github/workflows/[email protected]
secrets: inherit
permissions:
issues: write
pull-requests: write
with:
run-projects: true
project-labels: "knuu"
project-url: https://github.com/orgs/celestiaorg/projects/27

auto-add-reviewer:
name: Auto add reviewer to PR
if: github.event.pull_request
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Lint
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
merge_group:

jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22.1
# This steps sets the GIT_DIFF environment variable to true
# if files defined in PATTERS changed
- uses: technote-space/[email protected]
with:
# This job will pass without running if go.mod, go.sum, and *.go
# wasn't modified.
PATTERNS: |
**/**.go
go.mod
go.sum
- uses: golangci/[email protected]
with:
version: latest
args: --timeout 10m
github-token: ${{ secrets.github_token }}
if: env.GIT_DIFF

yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: celestiaorg/.github/.github/actions/[email protected]

markdown-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: celestiaorg/.github/.github/actions/[email protected]

govulncheck:
runs-on: ubuntu-latest
name: Run govulncheck
steps:
- id: govulncheck
uses: golang/govulncheck-action@v1
with:
go-version-input: 1.22.1
go-package: ./...
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage.txt
.vscode/launch.json
*/**.html
*.idea
46 changes: 46 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
run:
timeout: 5m
modules-download-mode: readonly

linters:
disable:
# TODO: there are tons of errors for these, we need to handle in a separate PR
- errorlint
- errcheck
- gosec
enable:
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- revive
- staticcheck
- typecheck
- unconvert
- unused

issues:
exclude-use-default: false
include:
- EXC0012 # EXC0012 revive: Annoying issue about not having a comment. The rare codebase has such comments
- EXC0014 # EXC0014 revive: Annoying issue about not having a comment. The rare codebase has such comments
exclude:
- SA1019 # TODO enable: SA 1019 staticcheck: this is being triggered by the refactor and all the deprecated code. We need to enable this once we make the breaking change official

linters-settings:
revive:
rules:
- name: package-comments
disabled: true
- name: duplicated-imports
severity: warning
- name: exported
disabled: true
# Leaving for reference if we can enable in the future.
# arguments:
# - disableStutteringCheck

goimports:
local-prefixes: github.com/celestiaorg
6 changes: 6 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
default: true
MD010: false
MD013: false
MD041: false
MD024:
allow_different_nesting: true
9 changes: 9 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# Built from docs https://yamllint.readthedocs.io/en/stable/configuration.html
extends: default

rules:
# 120 chars should be enough, but don't fail if a line is longer
line-length:
max: 120
level: warning
53 changes: 27 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,49 @@ If you are new to Knuu, please go through the [README](./README.md) to familiari

- Have a suggestion you want to implement? Open an issue, then create a Pull Request with your implementation.

- Want to resolve an issue in the repo, make a request to be assigned, and be sure to tag the issue in your PR!.
- Want to resolve an issue in the repo, make a request to be assigned, and be sure to tag the issue in your PR!

## Contribution Workflow

To contribute to Knuu, follow these steps:

1. Fork the repository: Click on the 'Fork' button at the top right of this page. This will create a copy of the repository in your GitHub account.

2. Clone the forked repository to your local machine. Open your terminal and run:

```bash
git clone <forked-repository-url>
```
1. Clone the forked repository to your local machine. Open your terminal and run:

3. Create your working branch: In the project directory, create a new branch by running the following command in your terminal:
```bash
git clone <forked-repository-url>
```

```bash
git checkout -b working-branch
```
Be sure to name your branch according to the changes you are making.
For example: `add-missing-tests`.
1. Create your working branch: In the project directory, create a new branch by running the following command in your terminal:

4. Make your changes: Do not address multiple issues per PR.
For example, if you are adding a feature, it should not have bug fixes too. This is to enable the maintainers review your PR efficiently.
```bash
git checkout -b working-branch
```

5. Commit the changes to your branch: After making the desired changes to the repo, run the following commands to commit them:
Be sure to name your branch according to the changes you are making.
For example: `add-missing-tests`.

```bash
git add .
```
1. Make your changes: Do not address multiple issues per PR.
For example, if you are adding a feature, it should not have bug fixes too. This is to enable the maintainers review your PR efficiently.

```bash
git commit -m "add an appropriate commit message"
```
1. Commit the changes to your branch: After making the desired changes to the repo, run the following commands to commit them:

```bash
git push origin <working-branch>
```
```bash
git add .
```

To ensure that your contribution is working as expected, please run `knuu-example` with your fork and working branch.
```bash
git commit -m "add an appropriate commit message"
```

5. Create a Pull Request: Go to your forked repository on GitHub, and be sure that you are in the branch you pushed the changes to. Click on the 'Compare & pull request' button. This will open a new page where you can create your PR. Fill in the description field and click on 'Create pull request'.
```bash
git push origin <working-branch>
```

To ensure that your contribution is working as expected, please run `knuu-example` with your fork and working branch.

1. Create a Pull Request: Go to your forked repository on GitHub, and be sure that you are in the branch you pushed the changes to. Click on the 'Compare & pull request' button. This will open a new page where you can create your PR. Fill in the description field and click on 'Create pull request'.
Be sure to name your PR with a semantic prefix. For example, if it is a fix, it should be specified with the `fix:` prefix.

Congratulations! You have successfully made a Pull Request, and your changes will be reviewed by the maintainers.
File renamed without changes.
59 changes: 57 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,62 @@ pkgs := $(shell go list ./...)
run := .
count := 1

## help: Show this help message
help: Makefile
@echo " Choose a command run in "$(PROJECTNAME)":"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
.PHONY: help

test:
go test -v $(pkgs) -run $(run) -count=$(count) -timeout 120m
## clean: clean testcache
clean:
@echo "--> Clearing testcache"
@go clean --testcache
@rm coverage.txt
.PHONY: clean

## cover: generate to code coverage report.
cover:
@echo "--> Generating Code Coverage"
@go install github.com/ory/go-acc@latest
@go-acc -o coverage.txt $(pkgs)
.PHONY: cover

## deps: Install dependencies
deps:
@echo "--> Installing dependencies"
@go mod download
@go mod tidy
.PHONY: deps

## lint: Run linters golangci-lint and markdownlint.
lint: vet
@echo "--> Running markdownlint"
@markdownlint --config .markdownlint.yaml '**/*.md'
@echo "--> Running yamllint"
@yamllint --no-warnings . -c .yamllint.yml
@echo "--> Running actionlint"
@actionlint
@echo "--> Running govulncheck"
@govulncheck ./...
@echo "--> Running golangci-lint"
@golangci-lint run
.PHONY: lint

## fmt: Run fixes for linters.
fmt:
@echo "--> Formatting markdownlint"
@markdownlint --config .markdownlint.yaml '**/*.md' -f
@echo "--> Formatting go"
@golangci-lint run --fix
.PHONY: fmt

## vet: Run go vet
vet:
@echo "--> Running go vet"
@go vet $(pkgs)
.PHONY: vet

## test: Run the testsuite
test: vet
go test -v $(pkgs) -run $(run) -count=$(count) -timeout 120m
.PHONY: test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ In the folder `e2e`, you will find some examples of how to use the [knuu](https:

## Write Tests

You can find the relevant documentation in the `pkg/knuu` package at: https://pkg.go.dev/github.com/celestiaorg/knuu
You can find the relevant documentation in the `pkg/knuu` package at: <https://pkg.go.dev/github.com/celestiaorg/knuu>

## Run

Expand Down Expand Up @@ -256,7 +256,7 @@ See [SECURITY.md](SECURITY.md) for security and disclosure information.

## Licensing

Knuu is licensed under the [Apache License 2.0](LICENSE).
Knuu is licensed under the [Apache License 2.0](./LICENSE).

<!---
## Contact
Expand Down
22 changes: 11 additions & 11 deletions docs/architecture/adr-001-redesign-knuu-async-approach.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ Node Configuration:
Playbook setup:

- **After reaching height 10**:
- Adjust the bandwidth of **15%** of Validators to **10Mbps**.
- Introduce a 50ms latency to **30%** of Light DA Nodes.
- Add a 20ms jitter to **25%** of Full DA Nodes.
- Adjust the bandwidth of **15%** of Validators to **10Mbps**.
- Introduce a 50ms latency to **30%** of Light DA Nodes.
- Add a 20ms jitter to **25%** of Full DA Nodes.

- **Test Duration**:
- Keep the test running until height **10,000**
- or **30 minutes**, ensuring comprehensive evaluation.
- Keep the test running until height **10,000**
- or **30 minutes**, ensuring comprehensive evaluation.

- **Metrics collection**
- Configured traffic shape on each node
- Error logs of each node
- Time to complete the sync of DA nodes
- Number of missing blocks to sign
- Number of missing blocks to propose
- ...
- Configured traffic shape on each node
- Error logs of each node
- Time to complete the sync of DA nodes
- Number of missing blocks to sign
- Number of missing blocks to propose
- ...

Each worker node receives this playbook and based on that decides what to do.
The entire playbook could be written in a golang code just like what Testground does.
Expand Down
5 changes: 0 additions & 5 deletions e2e/basic/bittwister_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,6 @@ func TestBittwister_Packetloss(t *testing.T) {
targetPacketlossRate: 90,
tolerancePercent: 10,
},
{
name: "100%",
targetPacketlossRate: 100,
tolerancePercent: 10,
},
}

targetIP, err := target.GetIP()
Expand Down
2 changes: 1 addition & 1 deletion e2e/basic/file_test_image_cached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestFileCached(t *testing.T) {
// adding the folder after the Commit, it will help us to use a cached image.
err = instance.AddFile("resources/html/index.html", "/usr/share/nginx/html/index.html", "0:0")
if err != nil {
t.Fatalf("Error adding file to '%v': %v", instanceName, err)
t.Errorf("Error adding file to '%v': %v", instanceName, err)
}
}(i, instance)
}
Expand Down
4 changes: 2 additions & 2 deletions e2e/basic/files_to_volumes_cm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestNoVolumesNoFiles(t *testing.T) {
t.Fatalf("Error creating executor: %v", err)
}

instanceName := fmt.Sprintf("web-1")
instanceName := "web-1"
instance, err := knuu.NewInstance(instanceName)
if err != nil {
t.Fatalf("Error creating instance '%v': %v", instanceName, err)
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestOneVolumeNoFiles(t *testing.T) {
t.Fatalf("Error creating executor: %v", err)
}

instanceName := fmt.Sprintf("web-1")
instanceName := "web-1"
instance, err := knuu.NewInstance(instanceName)
if err != nil {
t.Fatalf("Error creating instance '%v': %v", instanceName, err)
Expand Down
Loading

0 comments on commit 4fb750f

Please sign in to comment.