Skip to content

DST

DST #1819

Workflow file for this run

name: DST
on:
workflow_dispatch:
inputs:
seed:
type: string
schedule:
- cron: '0 */4 * * *' # every 4 hours
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@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
outputs:
seed: ${{ inputs.seed || steps.seed.outputs.seed }}
dst:
runs-on: ubuntu-22.04
needs: [build, seed]
timeout-minutes: 150
strategy:
fail-fast: false
matrix:
scenario: [default, fault, lazy]
store: [sqlite, postgres]
run: [1, 2]
env:
DST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_HOST: "localhost"
DST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PORT: "5432"
DST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_USERNAME: "username"
DST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD: "password"
DST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_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_STORE_CONFIG_POSTGRES_USERNAME }}
POSTGRES_PASSWORD: ${{ env.DST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_PASSWORD }}
POSTGRES_DB: ${{ env.DST_AIO_SUBSYSTEMS_STORE_CONFIG_POSTGRES_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.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
diff:
runs-on: ubuntu-22.04
needs: [build, seed, dst]
strategy:
fail-fast: false
matrix:
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
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