-
Notifications
You must be signed in to change notification settings - Fork 50
174 lines (171 loc) · 5.51 KB
/
rust.yml
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Rust
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
fmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Rust fmt
run: |
shopt -s globstar
rustfmt **/*.rs --check
contracts-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-contracts-${{ hashFiles('creusot-contracts/Cargo.lock') }}
- name: Build creusot-contracts with rustc
run: cargo build -p creusot-contracts
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build
- name: dummy creusot setup
run: |
mkdir -p ~/.config/creusot
cp ci/creusot-config-dummy.toml ~/.config/creusot/Config.toml
- name: Run tests
run: cargo test
why3-deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
id: cache-opam
with:
path: |
/home/runner/work/creusot/creusot/_opam
key: ${{ runner.os }}-opam-${{ hashFiles('creusot-deps.opam') }}
- uses: ocaml/setup-ocaml@v3
if: steps.cache-opam.outputs.cache-hit != 'true'
with:
ocaml-compiler: 4.14.1
- name: install opam dependencies
if: steps.cache-opam.outputs.cache-hit != 'true'
run: |
opam switch
opam --cli=2.1 var --global in-creusot-ci=true
opam install .
mkdir /tmp/to-delete
opam info --list-files why3 why3find > keep
sed -i 's/^.*\/_opam\///' keep
rsync -a -r --remove-source-files --exclude-from=keep _opam/ /tmp/to-delete
- name: archive why3 and why3find
run: tar -czf _opam.tar.gz _opam
# use tar because upload-artifact does not preserve file permissions
# https://github.com/actions/upload-artifact/tree/v4/?tab=readme-ov-file#permission-loss
- name: upload why3 and why3find
uses: actions/upload-artifact@v4
with:
name: why3-deps
path: _opam.tar.gz
why3:
needs: why3-deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event.pull_request.commits }}
- name: Fetch target branch
if: github.base_ref
run: git fetch --no-tags --prune --depth=1 origin +refs/heads/${{github.base_ref}}:refs/remotes/origin/${{github.base_ref}}
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-creusot-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/cache@v4
id: cache-creusot-setup
with:
path: |
~/.config/creusot
~/.local/share/creusot
_opam/lib/why3find/packages
key: ${{ runner.os }}-cargo-creusot-setup-${{ hashFiles('creusot-deps.opam', 'creusot-setup/src/tools_versions_urls.rs', 'creusot-setup/src/config.rs') }}
- name: download why3 and why3find
uses: actions/download-artifact@v4
with:
name: why3-deps
- name: setup opam PATH
run: |
tar -xzf _opam.tar.gz
echo /home/runner/work/creusot/creusot/_opam/bin >> $GITHUB_PATH
- name: run cargo creusot setup install
if: steps.cache-creusot-setup.outputs.cache-hit != 'true'
run: |
cargo run --bin cargo-creusot creusot setup install
echo -e "\n>> ~/.config/creusot/Config.toml:\n"
cat ~/.config/creusot/Config.toml
echo -e "\n>> ~/.config/creusot/why3.conf:\n"
cat ~/.config/creusot/why3.conf
- run: cargo test --test why3 "" -- --replay=none --diff-from=origin/master
- run: cargo test --test why3 "" -- --skip-unstable
install:
needs: why3-deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-install-${{ hashFiles('**/Cargo.lock') }}
- name: Install
run: |
cargo install --path cargo-creusot
cargo install --path creusot-rustc
- uses: actions/cache@v4
id: cache-creusot-setup
with:
path: |
~/.config/creusot
~/.local/share/creusot
_opam/lib/why3find/packages
key: ${{ runner.os }}-cargo-creusot-setup-${{ hashFiles('creusot-deps.opam', 'creusot-setup/src/tools_versions_urls.rs', 'creusot-setup/src/config.rs') }}
- name: download why3 and why3find
uses: actions/download-artifact@v4
with:
name: why3-deps
- name: unpack why3 and why3find
run: tar -xzf _opam.tar.gz
- name: setup creusot
run: |
# Add /home/runner/work/creusot/creusot/_opam/bin to PATH just for this step
export PATH=/home/runner/work/creusot/creusot/_opam/bin:$PATH
cargo creusot setup install
if: steps.cache-creusot-setup.outputs.cache-hit != 'true'
- name: test cargo creusot new
run: |
set -x
cd ..
cargo creusot new test-project --main --creusot-contracts ../creusot/creusot-contracts
cd test-project
cargo fmt --check
cargo build
cargo creusot
cargo creusot prove