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

gocoro refactor #356

Merged
merged 20 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 21 additions & 26 deletions .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ permissions:
contents: read

jobs:
check-default:
lint:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
Expand Down Expand Up @@ -47,31 +47,15 @@ jobs:
--verbose \
--timeout=3m

- name: Run go test and generate coverage report
run: |
nix develop --command \
go test \
-v \
-coverprofile=coverage.out \
-coverpkg=./... \
./...

- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4 # nosemgrep
with:
token: ${{ secrets.CODECOV_TOKEN }}
codecov_yml_path: codecov.yml

check-postgres:
test:
runs-on: ubuntu-22.04

env:
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_HOST: "localhost"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PORT: "5432"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME: "username"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD: "password"
TEST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_DATABASE: "resonate_test"

services:
postgres:
image: postgres:15
Expand All @@ -86,7 +70,7 @@ jobs:
--health-retries 5
ports:
- 5432:5432

steps:
- name: Check out repository
uses: actions/checkout@v4
Expand All @@ -97,12 +81,24 @@ jobs:
go-version-file: go.mod
cache: false

# Intentionally not using nix here as a workout around to the postgres dependency.
# Intentionally not using nix here as a workout around to the postgres dependency.
- name: Run go test and generate coverage report
run: |
go test -v -coverprofile=coverage.out -coverpkg=./... ./...

check-linearizability:
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v4 # nosemgrep
with:
token: ${{ secrets.CODECOV_TOKEN }}
codecov_yml_path: codecov.yml

- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: dst-results
path: test/dst/dst*.html

linearizability:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
Expand Down Expand Up @@ -137,22 +133,21 @@ jobs:
path: test/results/

scan:
name: semgrep
runs-on: ubuntu-20.04
needs: [check-default, check-postgres, check-linearizability]
needs: [lint, test, linearizability]
env:
SEMGREP_RULES: "auto semgrep.yml"
if: (github.actor != 'dependabot[bot]')
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11

- name: Use Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6

- name: semgrep
run: |
nix develop --command \
Expand Down
208 changes: 112 additions & 96 deletions .github/workflows/dst.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ name: DST

on:
workflow_dispatch:
inputs:
seed:
type: string
inputs:
seed:
type: number
ticks:
type: number
default: 1000
schedule:
- cron: '0 */4 * * *' # every 4 hours
- cron: "0 */4 * * *" # every 4 hours

permissions:
contents: read
Expand All @@ -16,32 +19,32 @@ jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11

- name: Use Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Build resonate binary
run: |
nix build ".#resonate"
cp ./result/bin/resonate resonate

- name: Cache resonate binary
uses: actions/cache/save@v4
with:
path: resonate
key: resonate-${{ github.sha }}
- name: Check out repository
uses: actions/checkout@v4

- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11

- name: Use Magic Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6

- name: Build resonate binary
run: |
nix build ".#resonate"
cp ./result/bin/resonate resonate

- name: Cache resonate binary
uses: actions/cache/save@v4
with:
path: resonate
key: resonate-${{ github.sha }}

seed:
runs-on: ubuntu-22.04
steps:
- id: seed
name: Set random seed
run: echo seed=$RANDOM >> $GITHUB_OUTPUT
- id: seed
name: Set random seed
run: echo seed=$RANDOM >> $GITHUB_OUTPUT
outputs:
seed: ${{ inputs.seed || steps.seed.outputs.seed }}

Expand Down Expand Up @@ -80,37 +83,49 @@ jobs:
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
- 5432:5432

steps:
- name: Restore resonate binary
uses: actions/cache/restore@v4
with:
path: resonate
key: resonate-${{ github.sha }}
fail-on-cache-miss: true
- name: Run dst (seed=${{ needs.seed.outputs.seed }}, scenario=${{ matrix.scenario }}, store=${{ matrix.store }})
run: |
./resonate dst run --seed ${{ needs.seed.outputs.seed }} --scenario ${{ matrix.scenario }} --aio-store ${{ matrix.store }} > logs.txt 2>&1
- name: Create issue if dst failed
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
if: ${{ failure() && matrix.run == 1 }}
run: |
./resonate dst issue \
--seed ${{ needs.seed.outputs.seed }} \
--scenario ${{ matrix.scenario }} \
--store ${{ matrix.store }} \
--reason "DST run failed for seed=${{ needs.seed.outputs.seed }}, scenario=${{ matrix.scenario }}, store=${{ matrix.store }}." \
--file logs.txt \
--repo $GITHUB_REPOSITORY \
--commit $GITHUB_SHA \
--url $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: ${{ matrix.scenario }}-${{ matrix.store }}-logs-${{ matrix.run }}
path: logs.txt
- name: Restore resonate binary
uses: actions/cache/restore@v4
with:
path: resonate
key: resonate-${{ github.sha }}
fail-on-cache-miss: true
- name: Run dst (seed=${{ needs.seed.outputs.seed }}, ticks=${{ inputs.ticks }}, scenario=${{ matrix.scenario }}, store=${{ matrix.store }})
run: |
./resonate dst run \
--seed ${{ needs.seed.outputs.seed }} \
--ticks ${{ inputs.ticks }} \
--timeout 2h \
--scenario ${{ matrix.scenario }} \
--aio-store ${{ matrix.store }} \
> logs.txt 2>&1
- name: Create issue if dst failed
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
if: ${{ failure() && matrix.run == 1 }}
run: |
./resonate dst issue \
--seed ${{ needs.seed.outputs.seed }} \
--ticks ${{ inputs.ticks }} \
--scenario ${{ matrix.scenario }} \
--store ${{ matrix.store }} \
--reason "DST run failed for seed=${{ needs.seed.outputs.seed }}, ticks=${{ inputs.ticks }}, scenario=${{ matrix.scenario }}, store=${{ matrix.store }}." \
--file logs.txt \
--repo $GITHUB_REPOSITORY \
--commit $GITHUB_SHA \
--url $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: ${{ matrix.scenario }}-${{ matrix.store }}-${{ matrix.run }}-logs
path: logs.txt
- uses: actions/upload-artifact@v4
if: ${{ always() && matrix.scenario != 'fault' }}
with:
name: ${{ matrix.scenario }}-${{ matrix.store }}-${{ matrix.run }}-visualization
path: dst.html

diff:
runs-on: ubuntu-22.04
Expand All @@ -122,46 +137,47 @@ jobs:
scenario: [default, fault, lazy]
store: [sqlite, postgres, sqlite/postgres]
include:
- store: sqlite
logs1: sqlite-logs-1
logs2: sqlite-logs-2
- store: postgres
logs1: postgres-logs-1
logs2: postgres-logs-2
- store: sqlite/postgres
logs1: sqlite-logs-1
logs2: postgres-logs-1
- store: sqlite
logs1: sqlite-1-logs
logs2: sqlite-2-logs
- store: postgres
logs1: postgres-1-logs
logs2: postgres-2-logs
- store: sqlite/postgres
logs1: sqlite-1-logs
logs2: postgres-1-logs

steps:
- name: Restore resonate binary
uses: actions/cache/restore@v4
with:
path: resonate
key: resonate-${{ github.sha }}
fail-on-cache-miss: true
- name: Download logs from run 1
uses: actions/download-artifact@v4
with:
name: ${{ matrix.scenario }}-${{ matrix.logs1 }}
path: logs-1.txt
- name: Download logs from run 2
uses: actions/download-artifact@v4
with:
name: ${{ matrix.scenario }}-${{ matrix.logs2 }}
path: logs-2.txt
- name: Diff
run: |
diff logs-1.txt logs-2.txt
- name: Create issue if diff
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
if: ${{ failure() }}
run: |
./resonate dst issue \
--seed ${{ needs.seed.outputs.seed }} \
--scenario ${{ matrix.scenario }} \
--store ${{ matrix.store }} \
--reason "Two DST runs produced different results for seed=${{ needs.seed.outputs.seed }}, scenario=${{ matrix.scenario }}, store=${{ matrix.store }}." \
--repo $GITHUB_REPOSITORY \
--commit $GITHUB_SHA \
--url $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Restore resonate binary
uses: actions/cache/restore@v4
with:
path: resonate
key: resonate-${{ github.sha }}
fail-on-cache-miss: true
- name: Download logs from run 1
uses: actions/download-artifact@v4
with:
name: ${{ matrix.scenario }}-${{ matrix.logs1 }}
path: logs-1.txt
- name: Download logs from run 2
uses: actions/download-artifact@v4
with:
name: ${{ matrix.scenario }}-${{ matrix.logs2 }}
path: logs-2.txt
- name: Diff
run: |
diff logs-1.txt logs-2.txt
- name: Create issue if diff
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
if: ${{ failure() }}
run: |
./resonate dst issue \
--seed ${{ needs.seed.outputs.seed }} \
--ticks ${{ inputs.ticks }} \
--scenario ${{ matrix.scenario }} \
--store ${{ matrix.store }} \
--reason "Two DST runs produced different results for seed=${{ needs.seed.outputs.seed }}, ticks=${{ inputs.ticks }}, scenario=${{ matrix.scenario }}, store=${{ matrix.store }}." \
--repo $GITHUB_REPOSITORY \
--commit $GITHUB_SHA \
--url $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ go.work
resonate*
coverage.out
.env
dst*.html

# ignore goland files
.idea
Expand Down
6 changes: 4 additions & 2 deletions cmd/dst/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

**Command**
~~~
go run ./... dst run --seed %d --scenario %s --aio-store %s
go run ./... dst run --seed %d --ticks %d --scenario %s --aio-store %s
~~~

**Logs**
Expand All @@ -56,6 +56,7 @@
func CreateDSTIssueCmd() *cobra.Command {
var (
seed int64
ticks int64

Check warning on line 59 in cmd/dst/issue.go

View check run for this annotation

Codecov / codecov/patch

cmd/dst/issue.go#L59

Added line #L59 was not covered by tests
scenario string
store string
reason string
Expand Down Expand Up @@ -87,14 +88,15 @@
// create github issue
issue := &Issue{
Title: fmt.Sprintf("DST: %d", seed),
Body: fmt.Sprintf(issueFmt, reason, seed, scenario, store, commit, seed, scenario, store, logs, url),
Body: fmt.Sprintf(issueFmt, reason, seed, scenario, store, commit, seed, ticks, scenario, store, logs, url),

Check warning on line 91 in cmd/dst/issue.go

View check run for this annotation

Codecov / codecov/patch

cmd/dst/issue.go#L91

Added line #L91 was not covered by tests
}

return createGitHubIssue(repo, token, issue)
},
}

cmd.Flags().Int64Var(&seed, "seed", 0, "dst seed")
cmd.Flags().Int64Var(&ticks, "ticks", 1000, "dst ticks")

Check warning on line 99 in cmd/dst/issue.go

View check run for this annotation

Codecov / codecov/patch

cmd/dst/issue.go#L99

Added line #L99 was not covered by tests
cmd.Flags().StringVar(&scenario, "scenario", "", "dst scenario")
cmd.Flags().StringVar(&store, "store", "", "dst store")
cmd.Flags().StringVar(&reason, "reason", "", "dst failure reason")
Expand Down
Loading