DST #3401
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: DST | |
on: | |
workflow_dispatch: | |
inputs: | |
seed: | |
description: "seed" | |
type: number | |
ticks: | |
description: "ticks" | |
type: number | |
schedule: | |
- cron: "0 * * * *" # every hour | |
permissions: | |
contents: read | |
issues: write | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Install Nix | |
uses: DeterminateSystems/nix-installer-action@v13 | |
- name: Use Magic Nix Cache | |
uses: DeterminateSystems/magic-nix-cache-action@v7 | |
- 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 }} | |
values: | |
runs-on: ubuntu-22.04 | |
steps: | |
- id: seed | |
name: Set random seed | |
run: echo seed=$RANDOM >> $GITHUB_OUTPUT | |
outputs: | |
seed: ${{ inputs.seed || steps.seed.outputs.seed }} | |
ticks: ${{ inputs.ticks || 1000 }} | |
dst: | |
runs-on: ubuntu-22.04 | |
needs: [build, values] | |
timeout-minutes: 150 | |
strategy: | |
fail-fast: false | |
matrix: | |
scenario: [default, fault, lazy] | |
store: [sqlite, postgres] | |
run: [1, 2] | |
env: | |
DST_AIO_SUBSYSTEMS_STOREPOSTGRES_CONFIG_HOST: "localhost" | |
DST_AIO_SUBSYSTEMS_STOREPOSTGRES_CONFIG_PORT: "5432" | |
DST_AIO_SUBSYSTEMS_STOREPOSTGRES_CONFIG_USERNAME: "username" | |
DST_AIO_SUBSYSTEMS_STOREPOSTGRES_CONFIG_PASSWORD: "password" | |
DST_AIO_SUBSYSTEMS_STOREPOSTGRES_CONFIG_DATABASE: "resonate_dst" | |
services: | |
postgres: | |
# workaround to conditionally start the service | |
# an empty string will skip starting the service | |
# see: https://github.com/actions/runner/issues/822 | |
image: ${{ matrix.store == 'postgres' && 'postgres:15' || '' }} | |
env: | |
POSTGRES_USER: ${{ env.DST_AIO_SUBSYSTEMS_STOREPOSTGRES_CONFIG_USERNAME }} | |
POSTGRES_PASSWORD: ${{ env.DST_AIO_SUBSYSTEMS_STOREPOSTGRES_CONFIG_PASSWORD }} | |
POSTGRES_DB: ${{ env.DST_AIO_SUBSYSTEMS_STOREPOSTGRES_CONFIG_DATABASE }} | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
ports: | |
- 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.values.outputs.seed }}, ticks=${{ needs.values.outputs.ticks }}, scenario=${{ matrix.scenario }}, store=${{ matrix.store }}) | |
run: | | |
./resonate dst run \ | |
--seed ${{ needs.values.outputs.seed }} \ | |
--ticks ${{ needs.values.outputs.ticks }} \ | |
--timeout 2h \ | |
--scenario ${{ matrix.scenario }} \ | |
--aio-store-${{ matrix.store }}-enable true \ | |
> 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.values.outputs.seed }} \ | |
--ticks ${{ needs.values.outputs.ticks }} \ | |
--scenario ${{ matrix.scenario }} \ | |
--store ${{ matrix.store }} \ | |
--reason "DST run failed for seed=${{ needs.values.outputs.seed }}, ticks=${{ needs.values.outputs.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 | |
needs: [build, values, dst] | |
strategy: | |
fail-fast: false | |
matrix: | |
scenario: [default, fault, lazy] | |
store: [sqlite, postgres, sqlite/postgres] | |
include: | |
- 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.values.outputs.seed }} \ | |
--ticks ${{ needs.values.outputs.ticks }} \ | |
--scenario ${{ matrix.scenario }} \ | |
--store ${{ matrix.store }} \ | |
--reason "Two DST runs produced different results for seed=${{ needs.values.outputs.seed }}, ticks=${{ needs.values.outputs.ticks }}, scenario=${{ matrix.scenario }}, store=${{ matrix.store }}." \ | |
--repo $GITHUB_REPOSITORY \ | |
--commit $GITHUB_SHA \ | |
--url $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID |