Skip to content

Commit 279d704

Browse files
committed
Initial implementation
1 parent de03399 commit 279d704

File tree

307 files changed

+31145
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+31145
-0
lines changed

.clippy.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
msrv = "1.36"

.editorconfig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# EditorConfig configuration
2+
# https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
indent_size = 4
10+
indent_style = space
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.{json,md,yml}]
15+
indent_size = 2
16+
17+
[*.yml]
18+
quote_type = single
19+
20+
[*.sh]
21+
binary_next_line = true
22+
switch_case_indent = true

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/bors.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
status = ["ci"]

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: /
5+
schedule:
6+
interval: daily
7+
commit-message:
8+
prefix: ''
9+
labels: []

.github/workflows/ci.yml

Lines changed: 298 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,298 @@
1+
name: CI
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- main
11+
- dev
12+
- staging
13+
schedule:
14+
- cron: '0 1 * * *'
15+
workflow_dispatch:
16+
17+
env:
18+
CARGO_INCREMENTAL: 0
19+
CARGO_NET_RETRY: 10
20+
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: full
22+
RUSTFLAGS: -D warnings
23+
RUSTUP_MAX_RETRIES: 10
24+
25+
defaults:
26+
run:
27+
shell: bash
28+
29+
jobs:
30+
test:
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include:
35+
- rust: stable
36+
- rust: beta
37+
- rust: nightly
38+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
39+
steps:
40+
- uses: actions/checkout@v2
41+
with:
42+
persist-credentials: false
43+
- uses: taiki-e/github-actions/install-rust@main
44+
with:
45+
toolchain: ${{ matrix.rust }}
46+
component: rust-src
47+
# thumbv7m-none-eabi/riscv32imac-unknown-none-elf/riscv32imc-esp-espidf: supports atomic CAS
48+
# thumbv6m-none-eabi: supports atomic load/store, but not atomic CAS
49+
# riscv32i-unknown-none-elf/riscv32imc-unknown-none-elf: does not support atomic at all
50+
# msp430-none-elf: 16-bit, does not support atomic at all
51+
target: thumbv7m-none-eabi,thumbv6m-none-eabi,riscv32i-unknown-none-elf,riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf
52+
- uses: taiki-e/install-action@cargo-hack
53+
- run: cargo test --workspace -- --test-threads=1
54+
- run: cargo test --workspace --release -- --test-threads=1
55+
- run: cargo test --workspace --release --all-features --exclude asm-test --tests -- --test-threads=1
56+
# opt-level=0, opt-level=1, opt-level=s, opt-level=z fail to remove panic.
57+
- run: cargo test --workspace --release --all-features --exclude asm-test --tests -- --test-threads=1
58+
env:
59+
RUSTFLAGS: ${{ env.RUSTFLAGS }} -C opt-level=2
60+
- run: cargo test --workspace -- --test-threads=1
61+
env:
62+
RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg atomic_memcpy_unsafe_volatile
63+
- run: cargo test --workspace --release --all-features --exclude asm-test --tests -- --test-threads=1
64+
env:
65+
RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg atomic_memcpy_unsafe_volatile
66+
- run: cargo hack build --workspace --ignore-private --feature-powerset --optional-deps --no-dev-deps
67+
- run: cargo hack build --workspace --ignore-private --feature-powerset --optional-deps --no-dev-deps
68+
env:
69+
RUSTFLAGS: ${{ env.RUSTFLAGS }} --cfg atomic_memcpy_unsafe_volatile
70+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --target thumbv7m-none-eabi
71+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --release --target thumbv7m-none-eabi
72+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --target thumbv6m-none-eabi
73+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --release --target thumbv6m-none-eabi
74+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --target riscv32i-unknown-none-elf
75+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --release --target riscv32i-unknown-none-elf
76+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --target riscv32imc-unknown-none-elf
77+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --release --target riscv32imc-unknown-none-elf
78+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --target riscv32imac-unknown-none-elf
79+
- run: cargo build --manifest-path tests/no-std/Cargo.toml --release --target riscv32imac-unknown-none-elf
80+
- run: cargo -Z build-std=core build --manifest-path tests/no-std/Cargo.toml --target riscv32imc-esp-espidf
81+
if: startsWith(matrix.rust, 'nightly')
82+
- run: cargo -Z build-std=core build --manifest-path tests/no-std/Cargo.toml --release --target riscv32imc-esp-espidf
83+
if: startsWith(matrix.rust, 'nightly')
84+
- run: cargo -Z build-std=core build --manifest-path tests/no-std/Cargo.toml --target msp430-none-elf
85+
if: startsWith(matrix.rust, 'nightly')
86+
- run: cargo -Z build-std=core build --manifest-path tests/no-std/Cargo.toml --release --target msp430-none-elf
87+
if: startsWith(matrix.rust, 'nightly')
88+
89+
cross:
90+
name: test (${{ matrix.target }})
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
include:
95+
- target: aarch64-unknown-linux-gnu
96+
- target: armv5te-unknown-linux-gnueabi
97+
- target: i686-unknown-linux-gnu
98+
- target: mips-unknown-linux-gnu
99+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
100+
steps:
101+
- uses: actions/checkout@v2
102+
with:
103+
persist-credentials: false
104+
- uses: taiki-e/github-actions/install-rust@main
105+
- uses: taiki-e/install-action@cross
106+
- run: cross test --workspace --target ${{ matrix.target }} -- --test-threads=1
107+
- run: cross test --workspace --release --target ${{ matrix.target }} -- --test-threads=1
108+
- run: cross test --workspace --release --all-features --exclude asm-test --tests --target ${{ matrix.target }} -- --test-threads=1
109+
110+
msrv:
111+
runs-on: ubuntu-latest
112+
steps:
113+
- uses: actions/checkout@v2
114+
with:
115+
persist-credentials: false
116+
- uses: taiki-e/install-action@cargo-hack
117+
# Make sure this crate can be built with MSRV and all later versions.
118+
# However, this takes time, so for PR, set the version interval.
119+
- run: cargo hack build --workspace --ignore-private --no-dev-deps --version-range ..
120+
if: github.event_name != 'pull_request'
121+
- run: cargo hack build --workspace --ignore-private --no-dev-deps --version-range .. --version-step 2
122+
if: github.event_name == 'pull_request'
123+
# for no-panic
124+
- run: cargo hack test --no-run --workspace --release --all-features --ignore-private --version-range 1.54..
125+
126+
# TODO
127+
# asm:
128+
# runs-on: ubuntu-latest
129+
# steps:
130+
# - uses: actions/checkout@v2
131+
# with:
132+
# persist-credentials: false
133+
# - uses: taiki-e/github-actions/install-rust@main
134+
# - run: cargo install --git https://github.com/taiki-e/cargo-asm.git --branch dev
135+
# - run: cargo run --manifest-path tests/asm-test/Cargo.toml
136+
# - run: git add -N . && git diff --exit-code
137+
138+
miri:
139+
runs-on: ubuntu-latest
140+
steps:
141+
- uses: actions/checkout@v2
142+
with:
143+
persist-credentials: false
144+
- uses: taiki-e/github-actions/install-rust@main
145+
with:
146+
component: miri
147+
- run: cargo miri test --workspace -- --test-threads=1
148+
env:
149+
MIRIFLAGS: -Zmiri-symbolic-alignment-check -Zmiri-tag-raw-pointers -Zmiri-disable-isolation
150+
# tests/padding.rs intentional contains tests for cases that are incompatible with -Zmiri-check-number-validity.
151+
- run: cargo miri test --test test -- --test-threads=1
152+
env:
153+
MIRIFLAGS: -Zmiri-check-number-validity -Zmiri-symbolic-alignment-check -Zmiri-tag-raw-pointers -Zmiri-disable-isolation
154+
155+
san:
156+
strategy:
157+
fail-fast: false
158+
matrix:
159+
sanitizer:
160+
- address
161+
- memory
162+
- thread
163+
runs-on: ubuntu-latest
164+
steps:
165+
- uses: actions/checkout@v2
166+
with:
167+
persist-credentials: false
168+
- uses: taiki-e/github-actions/install-rust@main
169+
with:
170+
component: rust-src
171+
- run: |
172+
cargo -Z build-std test --workspace --target "$(rustc -Vv | grep host | sed 's/host: //')" --tests -- --test-threads=1
173+
env:
174+
RUSTFLAGS: ${{ env.RUSTFLAGS }} -Z sanitizer=${{ matrix.sanitizer }}
175+
- run: |
176+
cargo -Z build-std test --workspace --release --target "$(rustc -Vv | grep host | sed 's/host: //')" --tests -- --test-threads=1
177+
env:
178+
RUSTFLAGS: ${{ env.RUSTFLAGS }} -Z sanitizer=${{ matrix.sanitizer }}
179+
180+
valgrind:
181+
env:
182+
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all
183+
runs-on: ubuntu-latest
184+
steps:
185+
- uses: actions/checkout@v2
186+
with:
187+
persist-credentials: false
188+
- uses: taiki-e/github-actions/install-rust@main
189+
- uses: taiki-e/install-action@valgrind
190+
- run: cargo test --workspace -- --test-threads=1
191+
- run: cargo test --workspace --release -- --test-threads=1
192+
193+
cov:
194+
runs-on: ubuntu-latest
195+
steps:
196+
- uses: actions/checkout@v2
197+
with:
198+
persist-credentials: false
199+
- uses: taiki-e/github-actions/install-rust@main
200+
with:
201+
component: llvm-tools-preview
202+
- uses: taiki-e/install-action@cargo-llvm-cov
203+
- run: cargo llvm-cov --workspace --text --hide-instantiations -- --test-threads=1
204+
- run: cargo llvm-cov --workspace --text --no-run
205+
206+
codegen:
207+
runs-on: ubuntu-latest
208+
permissions:
209+
contents: write
210+
pull-requests: write
211+
steps:
212+
- uses: actions/checkout@v2
213+
with:
214+
persist-credentials: false
215+
- uses: taiki-e/github-actions/install-rust@main
216+
- run: tools/no_atomic.sh
217+
- run: git add -N . && git diff --exit-code
218+
if: github.repository_owner != 'taiki-e' || github.event_name != 'schedule' && !(github.event_name == 'push' && github.ref == 'refs/heads/main')
219+
- id: diff
220+
run: |
221+
git config user.name "Taiki Endo"
222+
git config user.email "[email protected]"
223+
git add -N .
224+
if ! git diff --exit-code; then
225+
git add .
226+
git commit -m "Update tools/no_atomic"
227+
echo "::set-output name=success::false"
228+
fi
229+
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main')
230+
- uses: taiki-e/create-pull-request@v3
231+
with:
232+
title: Update tools/no_atomic
233+
body: |
234+
Auto-generated by [create-pull-request][1]
235+
[Please close and immediately reopen this pull request to run CI.][2]
236+
237+
[1]: https://github.com/peter-evans/create-pull-request
238+
[2]: https://github.com/peter-evans/create-pull-request/blob/HEAD/docs/concepts-guidelines.md#workarounds-to-trigger-further-workflow-runs
239+
branch: update-no-atomic-rs
240+
if: github.repository_owner == 'taiki-e' && (github.event_name == 'schedule' || github.event_name == 'push' && github.ref == 'refs/heads/main') && steps.diff.outputs.success == 'false'
241+
242+
tidy:
243+
runs-on: ubuntu-latest
244+
steps:
245+
- uses: actions/checkout@v2
246+
with:
247+
persist-credentials: false
248+
- uses: taiki-e/github-actions/install-rust@main
249+
with:
250+
component: clippy,rustfmt
251+
- uses: taiki-e/install-action@cargo-hack
252+
- uses: taiki-e/install-action@cargo-minimal-versions
253+
- uses: taiki-e/install-action@shellcheck
254+
- run: cargo fmt --all --check
255+
if: always()
256+
- run: cargo clippy --workspace --all-targets
257+
if: always()
258+
- run: cargo minimal-versions build --workspace --ignore-private
259+
if: always()
260+
- run: shellcheck $(git ls-files '*.sh')
261+
if: always()
262+
263+
docs:
264+
runs-on: ubuntu-latest
265+
steps:
266+
- uses: actions/checkout@v2
267+
with:
268+
persist-credentials: false
269+
- uses: taiki-e/github-actions/install-rust@main
270+
- run: cargo doc --workspace --document-private-items
271+
env:
272+
RUSTDOCFLAGS: -D warnings
273+
274+
# This job doesn't actually test anything, but they're used to tell bors the
275+
# build completed, as there is no practical way to detect when a workflow is
276+
# successful listening to webhooks only.
277+
#
278+
# ALL THE PREVIOUS JOBS NEEDS TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
279+
280+
ci-success:
281+
name: ci
282+
if: github.event_name == 'push' && success()
283+
needs:
284+
- test
285+
- cross
286+
- msrv
287+
# - asm
288+
- miri
289+
- san
290+
- valgrind
291+
- cov
292+
- codegen
293+
- tidy
294+
- docs
295+
runs-on: ubuntu-latest
296+
steps:
297+
- name: Mark the job as a success
298+
run: exit 0

.github/workflows/pr.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: PR
2+
3+
permissions:
4+
contents: read
5+
pull-requests: write
6+
7+
on:
8+
pull_request:
9+
types: [opened, reopened]
10+
11+
jobs:
12+
# This only affects PRs created by Dependabot.
13+
dependabot:
14+
if: startsWith(github.head_ref, 'dependabot/') && github.repository_owner == 'taiki-e'
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: taiki-e/github-actions/update-dependabot-pr@main
18+
env:
19+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)