-
-
Notifications
You must be signed in to change notification settings - Fork 17
173 lines (168 loc) · 6.17 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
name: Rust
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download Git submodules
run: git submodule update --init --recursive
- uses: coq-community/docker-coq-action@v1
with:
custom_image: coqorg/coq:8.17-ocaml-4.14-flambda
custom_script: |
startGroup "Install dependencies"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
source "$HOME/.cargo/env"
cargo --version
sudo ln -s `which python3` /usr/bin/python
opam install -y --deps-only CoqOfRust/coq-of-rust.opam
endGroup
startGroup "Build"
sudo chown -R $(whoami) .
cargo build --verbose
endGroup
startGroup "Install"
cargo install --path lib/
endGroup
startGroup "Format check"
cargo fmt --check
endGroup
startGroup "Lint"
cargo clippy --all-targets --all-features -- -D warnings
endGroup
startGroup "Translate Rust examples"
python run_tests.py
endGroup
startGroup "Pre-process the smart contracts"
cd contracts
python source_to_generated.py
cd generated
for dir in * ; do cd $dir ; cargo check ; cd .. ; done
cd ../..
endGroup
# We disable for now this translation as this makes a panic!
# startGroup "Translate Ink! library"
# cd CoqOfRust
# ./generate_ink_example.sh
# cd ..
# endGroup
startGroup "Save space"
cargo clean
endGroup
startGroup "Translate the alloc library"
cd third-party/rust/library/alloc
cp ../../../../rust-toolchain ./
cargo build
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/alloc/ --include='*/' --include='*.v' --exclude='*'
cd ../../../..
endGroup
startGroup "Translate the core library"
cd third-party/rust/library/core
cp ../../../../rust-toolchain ./
cargo build
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/core/ --include='*/' --include='*.v' --exclude='*'
cd ../../../..
endGroup
startGroup "Save space"
cd third-party/rust/library/alloc
cargo clean
cd ../../../..
cd third-party/rust/library/core
cargo clean
cd ../../../..
endGroup
startGroup "Translate Revm"
cd third-party/revm
cp ../../rust-toolchain ./
cd crates
# We compile each library twice to avoid errors. TODO: investigate why this is needed
# interpreter
cd interpreter
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/revm/translations/interpreter/ --include='*/' --include='*.v' --exclude='*'
cd ..
# precompile
cd precompile
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/revm/translations/precompile/ --include='*/' --include='*.v' --exclude='*'
cd ..
# primitives
cd primitives
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/revm/translations/primitives/ --include='*/' --include='*.v' --exclude='*'
cd ..
# revm
cd revm
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/revm/translations/revm/ --include='*/' --include='*.v' --exclude='*'
cd ..
cd ../../..
endGroup
startGroup "Translate Move Sui"
cd third-party/move-sui
cp ../../rust-toolchain ./
cd crates
# move-abstract-stack
cd move-abstract-stack
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/move_sui/translations/move_abstract_stack/ --include='*/' --include='*.v' --exclude='*'
cd ..
# move-binary-format
cd move-binary-format
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/move_sui/translations/move_binary_format/ --include='*/' --include='*.v' --exclude='*'
cd ..
# move-bytecode-verifier
cd move-bytecode-verifier
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/move_sui/translations/move_bytecode_verifier/ --include='*/' --include='*.v' --exclude='*'
cd ..
# move-bytecode-verifier-meter
cd move-bytecode-verifier-meter
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/move_sui/translations/move_bytecode_verifier_meter/ --include='*/' --include='*.v' --exclude='*'
cd ..
# move-core-types
cd move-core-types
cargo coq-of-rust
touch src/lib.rs
cargo coq-of-rust
rsync -acv src/ ../../../../CoqOfRust/move_sui/translations/move_core_types/ --include='*/' --include='*.v' --exclude='*'
cd ..
cd ../../..
endGroup
startGroup "Check that the diff is empty (excluding submodules)"
git -c color.ui=always diff --exit-code --ignore-submodules=dirty
endGroup
startGroup "Compile Coq translations"
cd CoqOfRust
python ./make_and_detect_warnings.py
cd ..
endGroup