-
Notifications
You must be signed in to change notification settings - Fork 21
128 lines (112 loc) · 3.99 KB
/
nightly-simulation.yml
File metadata and controls
128 lines (112 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: "Simulation Tests"
permissions:
contents: read
env:
AMARU_TEST_DATA_DIR: simulation/amaru-sim/test-data
RUST_BACKTRACE: full
RUST_MIN_STACK: 16777216
RUST_CACHE_PATH: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
on:
# This workflow runs on the main branch when there's a push
push:
branches: ["main"]
# This workflow can also be dispatched manually
workflow_dispatch:
inputs:
tests-number:
description: 'Number of tests'
required: true
default: 100
type: number
chain-depth:
description: 'Length of the longest generated chain'
required: true
default: 100
type: number
upstream-peers-number:
description: 'Number of upstream peers'
required: true
default: 4
type: number
test-seed:
description: 'Run with a specific seed (leave empty for a random seed)'
required: false
default: ''
type: string
schedule:
# run once a day on 1:00 AM
- cron: '0 1 * * *'
jobs:
run-simulation-tests:
name: Build ${{ matrix.environments.title }}
timeout-minutes: 600
strategy:
fail-fast: false
matrix:
# run only on linux for now.
environments:
- runner: ubuntu-latest
target: x86_64-unknown-linux-gnu
title: x86_64/linux
runs-on: ${{ matrix.environments.runner }}
steps:
# Set different test values depending on the github event:
# - schedule: use more larger parameters
# - push to main: use moderate parameters
# - manual run (workflow_dispatch): use user-provided parameters
- name: Set AMARU params for scheduled runs
if: ${{ github.event_name == 'schedule' }}
run: |
echo "AMARU_NUMBER_OF_TESTS=5000" >> $GITHUB_ENV
echo "AMARU_GENERATED_CHAIN_DEPTH=200" >> $GITHUB_ENV
echo "AMARU_NUMBER_OF_UPSTREAM_PEERS=4" >> $GITHUB_ENV
echo "AMARU_PERSIST_ON_SUCCESS=false" >> $GITHUB_ENV
- name: Set AMARU params for pushes to main
if: ${{ github.event_name == 'push' }}
run: |
echo "AMARU_NUMBER_OF_TESTS=200" >> $GITHUB_ENV
echo "AMARU_GENERATED_CHAIN_DEPTH=100" >> $GITHUB_ENV
echo "AMARU_NUMBER_OF_UPSTREAM_PEERS=2" >> $GITHUB_ENV
echo "AMARU_PERSIST_ON_SUCCESS=false" >> $GITHUB_ENV
- name: Set AMARU params for manual runs
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo "AMARU_NUMBER_OF_TESTS=${{ inputs.tests-number }}" >> $GITHUB_ENV
echo "AMARU_GENERATED_CHAIN_DEPTH=${{ inputs.chain-depth }}" >> $GITHUB_ENV
echo "AMARU_NUMBER_OF_UPSTREAM_PEERS=${{ inputs.upstream-peers-number }}" >> $GITHUB_ENV
- name: Set AMARU_TEST_SEED if provided
if: ${{ inputs.test-seed != '' }}
run: echo "AMARU_TEST_SEED=${{ inputs.test-seed }}" >> $GITHUB_ENV
- id: timestamp
run: echo "value=$(/bin/date -u '+%Y%m%d-%H%M%S')" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
submodules: true
- uses: actions/cache/restore@v4
with:
path: ${{ env.RUST_CACHE_PATH }}
key: cargo-${{ matrix.environments.target }}-${{ steps.timestamp.outputs.value }}
restore-keys: |
cargo-${{ matrix.environments.target }}
- name: Run tests
shell: bash
run: |
set -euo pipefail
LOG_DIR=simulation/amaru-sim/test-data
LOG_FILE="$LOG_DIR/simulation.log"
mkdir -p "$LOG_DIR"
# Print stderr only, save both streams
cargo run -p amaru-sim --locked --target ${{ matrix.environments.target }} \
1>>"$LOG_FILE" \
2> >(tee -a "$LOG_FILE" >&2)
- name: Upload test artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: failed-simulation-data
path: simulation/amaru-sim/test-data