1+ name : CI
2+
3+ on :
4+ push :
5+ branches :
6+ - ' **'
7+ tags :
8+ - ' v*.*.*'
9+ pull_request :
10+ branches :
11+ - ' **'
12+ schedule :
13+ - cron : ' 0 2 * * *' # Every day at 2am UTC
14+
15+ jobs :
16+ build-and-test :
17+ runs-on : ${{ matrix.os }}
18+ strategy :
19+ matrix :
20+ os : [ubuntu-latest, windows-latest, macos-latest]
21+
22+ steps :
23+ # Checkout the repository
24+ - name : Checkout code
25+ uses : actions/checkout@v3
26+
27+ # Set up Rust
28+ - name : Set up Rust
29+ uses : actions-rs/toolchain@v1
30+ with :
31+ toolchain : stable
32+ override : true
33+
34+ # Cache Cargo dependencies
35+ - name : Cache Cargo registry
36+ uses : actions/cache@v3
37+ with :
38+ path : ~/.cargo/registry
39+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
40+ restore-keys : |
41+ ${{ runner.os }}-cargo-registry-
42+
43+ - name : Cache Cargo build
44+ uses : actions/cache@v3
45+ with :
46+ path : target
47+ key : ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
48+ restore-keys : |
49+ ${{ runner.os }}-cargo-build-
50+
51+ # Build the project
52+ - name : Build
53+ run : cargo build --workspace --all-targets
54+
55+ # Prepare foundation file for Windows tests
56+ - name : Copy foundation_floonet.json to target/debian (Windows only)
57+ if : runner.os == 'Windows'
58+ shell : pwsh
59+ run : |
60+ New-Item -ItemType Directory -Path target\debian -Force
61+ Copy-Item debian\foundation_floonet.json target\debian\foundation_floonet.json -Force
62+
63+ # Run tests
64+ - name : Run tests
65+ run : cargo test --workspace -- --nocapture --test-threads=1
66+
67+ release :
68+ needs : build-and-test
69+ runs-on : ubuntu-latest
70+ if : startsWith(github.ref, 'refs/tags/')
71+ steps :
72+ - name : Checkout code
73+ uses : actions/checkout@v3
74+
75+ - name : Set up Rust
76+ uses : actions-rs/toolchain@v1
77+ with :
78+ toolchain : stable
79+ override : true
80+
81+ - name : Build release binaries
82+ run : cargo build --release --workspace
83+
84+ - name : Generate checksums
85+ run : |
86+ cd target/release
87+ for f in *; do
88+ if [ -x "$f" ] && [ ! -d "$f" ]; then
89+ shasum -a 256 "$f" > "$f.sha256"
90+ fi
91+ done
92+
93+ - name : Create GitHub Release
94+ uses : softprops/action-gh-release@v2
95+ with :
96+ files : |
97+ target/release/*
98+ !target/release/.*
99+ env :
100+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
101+
102+ cucumber-tests :
103+ if : github.ref == 'refs/heads/main' || github.event_name == 'schedule'
104+ runs-on : ubuntu-latest
105+ steps :
106+ # Checkout the repository
107+ - name : Checkout code
108+ uses : actions/checkout@v3
109+
110+ # Set up Rust
111+ - name : Set up Rust
112+ uses : actions-rs/toolchain@v1
113+ with :
114+ toolchain : stable
115+ override : true
116+
117+ # Cache Cargo dependencies
118+ - name : Cache Cargo registry
119+ uses : actions/cache@v3
120+ with :
121+ path : ~/.cargo/registry
122+ key : ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
123+ restore-keys : |
124+ ${{ runner.os }}-cargo-registry-
125+
126+ - name : Cache Cargo build
127+ uses : actions/cache@v3
128+ with :
129+ path : target
130+ key : ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }}
131+ restore-keys : |
132+ ${{ runner.os }}-cargo-build-
133+
134+ # Build the project
135+ - name : Build
136+ run : cargo build --workspace --all-targets
137+
138+ # Run cucumber tests
139+ - name : Run cucumber tests
140+ run : cargo test --test cucumber --features cucumber-tests -- --nocapture
0 commit comments