Skip to content

Commit

Permalink
chore: fix github actions and reduce simulation test blocks (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronCQL authored Aug 15, 2023
1 parent 09470b2 commit ca3fdf6
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 59 deletions.
61 changes: 31 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,15 @@
on: [push, pull_request]
name: every commit
jobs:

build:
runs-on: ubuntu-latest
name: build
steps:
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: 1.20.0
- run: go build ./...

test:
runs-on: ubuntu-latest
name: test
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.0
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: go test ./...
name: Build
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, reopened]

# Use --check or --exit-code when available (Go 1.19?)
# https://github.com/golang/go/issues/27005
jobs:
# Use --check or --exit-code when available (Go 1.19?)
# https://github.com/golang/go/issues/27005
tidy:
runs-on: ubuntu-latest
name: tidy
steps:
- uses: actions/checkout@v3
- name: Setup go
Expand All @@ -45,3 +24,25 @@ jobs:
git status && git --no-pager diff
exit 1
fi
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: 1.20.0
- run: go build ./...

unit-test:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: 1.20.0
- name: Checkout code
uses: actions/checkout@v3
- name: Test
run: go test ./...
11 changes: 5 additions & 6 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Run Gosec
name: Gosec
on:
push:
branches:
- main
branches: [main]
pull_request:
branches:
- main
types: [opened, synchronize, reopened]

jobs:
tests:
scan:
runs-on: ubuntu-latest
env:
GO111MODULE: on
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: Lint
# This workflow is run on every pull request and push to main
# The `golangci` job will pass without running if no *.{go, mod, sum} files have been modified.
on:
pull_request:
push:
branches:
- main
branches: [main]
pull_request:
types: [opened, synchronize, reopened]

jobs:
golangci:
name: golangci-lint
lint:
runs-on: ubuntu-latest
steps:
- name: Setup Go
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/simulation-test.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Simulation Test

name: Simulation
on:
# Triggers the workflow on pull request events but only for the 'main' branch
push:
branches: [main]
pull_request:
branches: ["main"]
workflow_dispatch:
types: [opened, synchronize, reopened]

jobs:
simulation-test:
Expand All @@ -16,11 +15,10 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
go-version-file: "go.mod"

- name: Download Modules
run: go mod download

- name: Test
id: test
run: go test -v -run=TestFullAppSimulation ./app -NumBlocks 200 -BlockSize 50 -Commit -Enabled -Period 1
- name: Simulation Test
run: go test ./app -run=TestFullAppSimulation -mod=readonly -Enabled=true -NumBlocks=100 -BlockSize=50 -Commit=true -Period=0 -v -timeout=24h
16 changes: 7 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ distclean: clean
### Testing ###
###############################################################################

SIM_PKG = ./app

test: test-unit

# For feather to use to test feather-cored correctness. E.g. make --jobs=4 test-all
Expand All @@ -229,25 +227,25 @@ test-benchmark:
@go test -mod=readonly -bench=. ./...

# Convenience target for running all simulation tests.
simulate: simulate-nondeterminism simulate-full-app simulate-app-import-export
simulate: simulate-full-app simulate-nondeterminism simulate-app-import-export

# Runs the simulation, checking invariants every operation.
simulate-full-app:
@echo "Running full application simulation..."
@$(GO) test -mod=readonly -run=TestFullAppSimulation ./app -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -v -timeout 24h
@$(GO) test ./app -run=TestFullAppSimulation \
-mod=readonly -Enabled=true -NumBlocks=100 -BlockSize=50 -Commit=true -Period=0 -v -timeout=24h

# Runs the same simulation multiple times, verifying that the resulting app hash is the same each time.
simulate-nondeterminism:
@echo "Running non-determinism simulation..."
@$(GO) test -mod=readonly $(SIM_PKG) -run TestAppStateDeterminism -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
@$(GO) test ./app -run=TestAppStateDeterminism \
-mod=readonly -Enabled=true -NumBlocks=100 -BlockSize=50 -Commit=true -Period=0 -v -timeout=24h

# Exports and imports genesis state, verifying that no data is lost in the process.
simulate-app-import-export:
@echo "Running genesis export/import simulation..."
@$(GO) test -v -run=TestAppImportExport ./app -Enabled=true \
-NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h
@$(GO) test ./app -run=TestAppImportExport \
-mod=readonly -Enabled=true -NumBlocks=100 -BlockSize=50 -Commit=true -Period=0 -v -timeout=24h

integration-test: clean-integration-test-data install
@echo "Initializing both blockchains..."
Expand Down

0 comments on commit ca3fdf6

Please sign in to comment.