Skip to content

Commit ab31934

Browse files
committed
Initial implementation
1 parent 59fe685 commit ab31934

File tree

441 files changed

+91459
-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.

441 files changed

+91459
-0
lines changed

.clippy.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Clippy configuration
2+
# https://doc.rust-lang.org/nightly/clippy/lint_configuration.html
3+
4+
allow-private-module-inception = true
5+
avoid-breaking-exported-api = false
6+
disallowed-names = []
7+
disallowed-macros = [
8+
{ path = "std::dbg", reason = "it is okay to use during development, but please do not include it in main branch" },
9+
]
10+
disallowed-methods = [
11+
]
12+
disallowed-types = [
13+
]

.cspell.json

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"version": "0.2",
3+
"gitignoreRoot": ".",
4+
"useGitignore": true,
5+
"dictionaryDefinitions": [
6+
{
7+
"name": "organization-dictionary",
8+
"path": "https://raw.githubusercontent.com/taiki-e/github-actions/HEAD/.github/.cspell/organization-dictionary.txt",
9+
"addWords": true
10+
},
11+
{
12+
"name": "project-dictionary",
13+
"path": "./.github/.cspell/project-dictionary.txt",
14+
"addWords": true
15+
},
16+
{
17+
"name": "rust-dependencies",
18+
"path": "./.github/.cspell/rust-dependencies.txt",
19+
"addWords": true
20+
}
21+
],
22+
"dictionaries": [
23+
"organization-dictionary",
24+
"project-dictionary",
25+
"rust-dependencies"
26+
],
27+
"ignoreRegExpList": [
28+
// Copyright notice
29+
"Copyright .*",
30+
// GHA actions/workflows
31+
"uses: .+@",
32+
// GHA context (repo name, owner name, etc.)
33+
"github.\\w+ (=|!)= '.+'",
34+
// GH username
35+
"( |\\[)@[\\w_-]+",
36+
// Git config username
37+
"git config user.name .*",
38+
// Username in todo comment
39+
"(TODO|FIXME)\\([\\w_., -]+\\)",
40+
// Cargo.toml authors
41+
"authors *= *\\[.*\\]",
42+
"\".* <[\\w_.+-]+@[\\w.-]+>\""
43+
],
44+
"languageSettings": [
45+
{
46+
"languageId": ["*"],
47+
"dictionaries": ["bash", "rust"]
48+
}
49+
],
50+
"ignorePaths": ["tests/external/**", "tests/fixtures/**"]
51+
}

.deny.toml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
2+
[advisories]
3+
yanked = "deny"
4+
git-fetch-with-cli = true
5+
ignore = [
6+
]
7+
8+
# https://embarkstudios.github.io/cargo-deny/checks/bans/cfg.html
9+
[bans]
10+
multiple-versions = "warn"
11+
wildcards = "deny"
12+
allow-wildcard-paths = true
13+
build.executables = "deny"
14+
build.interpreted = "deny"
15+
build.include-dependencies = true
16+
build.include-workspace = false # covered by tools/tidy.sh
17+
build.include-archives = true
18+
build.allow-build-scripts = [
19+
{ name = "proc-macro2" }, # via serde_derive
20+
{ name = "serde_json" },
21+
{ name = "serde" },
22+
]
23+
build.bypass = [
24+
]
25+
26+
# https://embarkstudios.github.io/cargo-deny/checks/licenses/cfg.html
27+
[licenses]
28+
unused-allowed-license = "deny"
29+
private.ignore = true
30+
allow = [
31+
"Apache-2.0",
32+
"MIT",
33+
"Unicode-3.0", # unicode-ident
34+
]
35+
36+
# https://embarkstudios.github.io/cargo-deny/checks/sources/cfg.html
37+
[sources]
38+
unknown-registry = "deny"
39+
unknown-git = "deny"
40+
allow-git = [
41+
]

.editorconfig

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
[*.{css,html,json,md,rb,sh,yml,yaml}]
15+
indent_size = 2
16+
17+
[*.{js,yml,yaml}]
18+
quote_type = single
19+
20+
[*.sh]
21+
# https://google.github.io/styleguide/shellguide.html#s5.3-pipelines
22+
binary_next_line = true
23+
# https://google.github.io/styleguide/shellguide.html#s5.5-case-statement
24+
switch_case_indent = true

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto eol=lf
2+
.github/.cspell/rust-dependencies.txt linguist-generated
3+
src/gen/** linguist-generated
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
acvf
2+
binstall
3+
buildah
4+
buildkit
5+
Dockerfilefromarg
6+
dockerfiles
7+
enquote
8+
hfuzz
9+
jeztah
10+
libunwind
11+
machdep
12+
memrchr
13+
moby
14+
nofrom
15+
onbuild
16+
shykes
17+
TARGETPLATFORM
18+
testdata
19+
thrpt
20+
unparse

.github/.cspell/rust-dependencies.txt

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/dependabot.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directories:
5+
- /
6+
# crates with [workspace] table are not recognized by the above 'directory: /'
7+
- /fuzz
8+
schedule:
9+
interval: daily
10+
commit-message:
11+
prefix: ''
12+
labels: []
13+
- package-ecosystem: github-actions
14+
directory: /
15+
schedule:
16+
interval: daily
17+
commit-message:
18+
prefix: ''
19+
labels: []

.github/workflows/ci.yml

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: CI
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- main
11+
- dev
12+
schedule:
13+
- cron: '0 2 * * *'
14+
workflow_dispatch:
15+
16+
env:
17+
CARGO_INCREMENTAL: 0
18+
CARGO_NET_GIT_FETCH_WITH_CLI: true
19+
CARGO_NET_RETRY: 10
20+
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: 1
22+
RUSTDOCFLAGS: -D warnings
23+
RUSTFLAGS: -D warnings
24+
RUSTUP_MAX_RETRIES: 10
25+
26+
defaults:
27+
run:
28+
shell: bash --noprofile --norc -CeEuxo pipefail {0}
29+
30+
concurrency:
31+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
32+
cancel-in-progress: true
33+
34+
jobs:
35+
miri:
36+
uses: taiki-e/github-actions/.github/workflows/miri.yml@main
37+
with:
38+
# NB: sync with test job's --exclude option
39+
args: --exclude parse-dockerfile-internal-codegen
40+
msrv:
41+
uses: taiki-e/github-actions/.github/workflows/msrv.yml@main
42+
release-dry-run:
43+
uses: taiki-e/github-actions/.github/workflows/release-dry-run.yml@main
44+
test:
45+
uses: taiki-e/github-actions/.github/workflows/test.yml@main
46+
with:
47+
# NB: sync with miri job's --exclude option
48+
test-args: --exclude parse-dockerfile-internal-codegen
49+
build-args: --lib
50+
no-std: false
51+
tidy:
52+
uses: taiki-e/github-actions/.github/workflows/tidy.yml@main
53+
permissions:
54+
contents: read
55+
pull-requests: write # for gh pr edit --add-assignee
56+
repository-projects: read # for gh pr edit --add-assignee
57+
secrets: inherit
58+
59+
fuzz:
60+
env:
61+
FUZZ_MAX_TOTAL_TIME: 60 # 1 minute
62+
runs-on: ubuntu-latest
63+
timeout-minutes: 60
64+
steps:
65+
- uses: taiki-e/checkout-action@v1
66+
- uses: taiki-e/github-actions/install-rust@nightly
67+
- run: sudo apt-get -o Acquire::Retries=10 -qq update && sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends binutils-dev libunwind8-dev
68+
- uses: taiki-e/cache-cargo-install-action@v2
69+
with:
70+
tool: cargo-fuzz
71+
# We cannot use cache for cargo-afl because afl.rs requires the cargo-afl binary and afl library to be built with the same compiler version.
72+
- run: cargo install cargo-afl --debug --locked
73+
- uses: taiki-e/cache-cargo-install-action@v2
74+
with:
75+
# TODO: Pass --no-default-features
76+
tool: honggfuzz
77+
- run: cargo fuzz build --features libfuzzer
78+
- run: cargo afl build --release --features afl
79+
working-directory: fuzz
80+
- run: |
81+
HFUZZ_BUILD_ARGS="--features honggfuzz" \
82+
RUSTFLAGS="${RUSTFLAGS:-} -Z sanitizer=address" \
83+
cargo hfuzz build
84+
working-directory: fuzz
85+
# On scheduled job, run fuzzer $FUZZ_MAX_TOTAL_TIME seconds per target.
86+
# TODO: This is currently skipped for libfuzzer due to https://github.com/rust-fuzz/cargo-fuzz/issues/270.
87+
# TODO: Honggfuzz
88+
- name: Cache AFL++ output
89+
uses: actions/cache@v4
90+
with:
91+
path: fuzz/out
92+
key: afl-out-${{ github.run_id }}
93+
restore-keys: afl-out-
94+
if: github.event_name == 'schedule'
95+
- name: Fuzzing with AFL++
96+
run: |
97+
sudo tee -- /proc/sys/kernel/core_pattern >/dev/null <<<core
98+
# shellcheck disable=SC2010
99+
for target in $(ls | grep -E '\.rs$' | sed -E 's/\.rs$//'); do
100+
cargo afl fuzz -i "seeds/${target}" -o "out/${target}" -V "${FUZZ_MAX_TOTAL_TIME}" "target/release/${target}"
101+
rmdir -- "out/${target}/default/crashes" 2>/dev/null || true
102+
rmdir -- "out/${target}/default/hangs" 2>/dev/null || true
103+
if [[ -d "out/${target}/default/crashes" ]] || [[ -d "out/${target}/default/hangs" ]]; then
104+
exit 1
105+
fi
106+
done
107+
working-directory: fuzz
108+
if: github.event_name == 'schedule'
109+
- name: Archive artifacts
110+
run: |
111+
if [[ -d out ]]; then
112+
tar acvf ../afl-artifacts.tar.gz out
113+
fi
114+
working-directory: fuzz
115+
if: failure() && github.event_name == 'schedule'
116+
- name: Upload artifacts
117+
uses: actions/upload-artifact@v4
118+
with:
119+
name: fuzz-artifacts
120+
path: afl-artifacts.tar.gz
121+
if: failure() && github.event_name == 'schedule'

.github/workflows/release.yml

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Release
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
tags:
9+
- v[0-9]+.*
10+
11+
env:
12+
CARGO_INCREMENTAL: 0
13+
CARGO_NET_GIT_FETCH_WITH_CLI: true
14+
CARGO_NET_RETRY: 10
15+
CARGO_TERM_COLOR: always
16+
RUST_BACKTRACE: 1
17+
RUSTFLAGS: -D warnings
18+
RUSTUP_MAX_RETRIES: 10
19+
20+
defaults:
21+
run:
22+
shell: bash --noprofile --norc -CeEuxo pipefail {0}
23+
24+
jobs:
25+
create-release:
26+
if: github.repository_owner == 'taiki-e'
27+
uses: taiki-e/github-actions/.github/workflows/create-release.yml@main
28+
permissions:
29+
contents: write
30+
secrets: inherit
31+
32+
upload-assets:
33+
name: ${{ matrix.target }}
34+
if: github.repository_owner == 'taiki-e'
35+
needs: create-release
36+
strategy:
37+
matrix:
38+
include:
39+
- target: aarch64-unknown-linux-gnu
40+
os: ubuntu-20.04
41+
- target: aarch64-unknown-linux-musl
42+
- target: aarch64-apple-darwin
43+
os: macos-13
44+
- target: aarch64-pc-windows-msvc
45+
os: windows-2019
46+
- target: x86_64-unknown-linux-gnu
47+
os: ubuntu-20.04
48+
- target: x86_64-unknown-linux-musl
49+
- target: x86_64-apple-darwin
50+
os: macos-13
51+
- target: x86_64-pc-windows-msvc
52+
os: windows-2019
53+
- target: x86_64-unknown-freebsd
54+
- target: x86_64-unknown-illumos
55+
- target: universal-apple-darwin
56+
os: macos-13
57+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
58+
timeout-minutes: 60
59+
permissions:
60+
contents: write
61+
steps:
62+
- uses: taiki-e/checkout-action@v1
63+
- uses: taiki-e/github-actions/install-rust@stable
64+
- uses: taiki-e/setup-cross-toolchain-action@v1
65+
with:
66+
target: ${{ matrix.target }}
67+
- run: printf '%s\n' "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static" >>"${GITHUB_ENV}"
68+
if: contains(matrix.target, '-windows-msvc')
69+
- run: printf '%s\n' "RUSTFLAGS=${RUSTFLAGS} -C target-feature=+crt-static -C link-self-contained=yes" >>"${GITHUB_ENV}"
70+
if: contains(matrix.target, '-linux-musl')
71+
# https://doc.rust-lang.org/rustc/platform-support.html
72+
- run: printf 'MACOSX_DEPLOYMENT_TARGET=10.12\n' >>"${GITHUB_ENV}"
73+
if: matrix.target == 'x86_64-apple-darwin'
74+
- run: printf 'MACOSX_DEPLOYMENT_TARGET=11.0\n' >>"${GITHUB_ENV}"
75+
if: matrix.target == 'aarch64-apple-darwin' || matrix.target == 'universal-apple-darwin'
76+
- uses: taiki-e/upload-rust-binary-action@v1
77+
with:
78+
bin: parse-dockerfile
79+
target: ${{ matrix.target }}
80+
tar: all
81+
zip: windows
82+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)