From 49f8a6f86a3ae5cd2c2c2de2a04a1b4eadb0ac29 Mon Sep 17 00:00:00 2001 From: Benjamin Brienen Date: Fri, 8 Nov 2024 21:50:53 +0100 Subject: [PATCH] Infrastructure --- .gitattributes | 14 + .github/FUNDING.yml | 1 + .github/ISSUE_TEMPLATE/bug_report.md | 54 +++ .github/ISSUE_TEMPLATE/config.yml | 9 + .github/ISSUE_TEMPLATE/docs_improvement.md | 13 + .github/ISSUE_TEMPLATE/feature_request.md | 24 ++ .../ISSUE_TEMPLATE/performance_regression.md | 67 +++ .github/dependabot.yml | 14 + .github/example-run/all_tuples.ron | 2 + .github/linters/.markdown-lint.yml | 9 + .github/pull_request_template.md | 42 ++ .github/workflows copy/ci.yml | 0 .github/workflows/action-on-PR-labeled.yml | 30 ++ .github/workflows/ci-comment-failures.yml | 172 ++++++++ .github/workflows/ci.yml | 406 +++++++++++++++++- .github/workflows/dependencies.yml | 61 +++ .github/workflows/post-release.yml | 56 +++ .github/workflows/release.yml | 53 +++ .../send-screenshots-to-pixeleagle.yml | 94 ++++ .github/workflows/validation-jobs.yml | 234 ++++++++++ .github/workflows/weekly.yml | 111 +++++ .github/workflows/welcome.yml | 47 ++ .gitignore | 33 +- Cargo.toml | 28 +- README.md | 1 + documentation/debugging.md | 8 + documentation/linters.md | 47 ++ errors/Cargo.toml | 12 + errors/README.md | 3 + errors/V0001.md | 3 + errors/src/lib.rs | 4 + tools/compile_fail_utils/Cargo.toml | 15 + tools/compile_fail_utils/README.md | 30 ++ tools/compile_fail_utils/src/lib.rs | 126 ++++++ tools/compile_fail_utils/tests/example.rs | 10 + .../tests/example_tests/basic_test.rs | 23 + .../tests/example_tests/basic_test.stderr | 39 ++ .../tests/example_tests/import.rs | 7 + .../tests/example_tests/import.stderr | 20 + .../tests/example_tests/pass_test.rs | 10 + .../tests/example_tests/pass_test.stderr | 10 + tools/publish.sh | 29 ++ typos.toml | 23 + 43 files changed, 1949 insertions(+), 45 deletions(-) create mode 100644 .gitattributes create mode 100644 .github/FUNDING.yml create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/docs_improvement.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/performance_regression.md create mode 100644 .github/dependabot.yml create mode 100644 .github/example-run/all_tuples.ron create mode 100644 .github/linters/.markdown-lint.yml create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows copy/ci.yml create mode 100644 .github/workflows/action-on-PR-labeled.yml create mode 100644 .github/workflows/ci-comment-failures.yml create mode 100644 .github/workflows/dependencies.yml create mode 100644 .github/workflows/post-release.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/send-screenshots-to-pixeleagle.yml create mode 100644 .github/workflows/validation-jobs.yml create mode 100644 .github/workflows/weekly.yml create mode 100644 .github/workflows/welcome.yml create mode 100644 documentation/debugging.md create mode 100644 documentation/linters.md create mode 100644 errors/Cargo.toml create mode 100644 errors/README.md create mode 100644 errors/V0001.md create mode 100644 errors/src/lib.rs create mode 100644 tools/compile_fail_utils/Cargo.toml create mode 100644 tools/compile_fail_utils/README.md create mode 100644 tools/compile_fail_utils/src/lib.rs create mode 100644 tools/compile_fail_utils/tests/example.rs create mode 100644 tools/compile_fail_utils/tests/example_tests/basic_test.rs create mode 100644 tools/compile_fail_utils/tests/example_tests/basic_test.stderr create mode 100644 tools/compile_fail_utils/tests/example_tests/import.rs create mode 100644 tools/compile_fail_utils/tests/example_tests/import.stderr create mode 100644 tools/compile_fail_utils/tests/example_tests/pass_test.rs create mode 100644 tools/compile_fail_utils/tests/example_tests/pass_test.stderr create mode 100644 tools/publish.sh create mode 100644 typos.toml diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f4a45cb --- /dev/null +++ b/.gitattributes @@ -0,0 +1,14 @@ +# From: https://docs.github.com/en/github/getting-started-with-github/configuring-git-to-handle-line-endings +# Set the default behavior, in case people don't have core.autocrlf set. +* text=auto + +# Explicitly declare text files you want to always be normalized and converted +# to native line endings on checkout. +.gitattributes text eol=lf +.gitignore text eol=lf +*.json text eol=lf +*.md text eol=lf +*.rs text eol=lf +*.sh text eol=lf +*.toml text eol=lf +*.yml text eol=lf diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..c4f6e2b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: https://bevyengine.org/donate/ diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..26a66fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,54 @@ +--- +name: Bug Report +about: Report a bug to help us improve! +title: '' +labels: C-Bug, S-Needs-Triage +assignees: '' +--- + +## `variadics_please` version + +The release number or commit hash of the version you're using. + +## Relevant system information + +This section is optional. Remove it if you know that the problem is not platform dependent. + +Rust version you're using: (`cargo --version`) + +```text + +``` + +> Notes: +> +> - Pay attention to the msrv (minimum supported rust version) of `variadics_please`. +> - `nightly` should work, but sometimes there are regressions: please let us know! + +Operating system, including version: + +```text + +``` + +## What you did + +Describe how you arrived at the problem. If you can, consider providing a code snippet or link. + +## What went wrong + +If it's not clear, break this out into: + +- what were you expecting? +- what actually happened? + +## Additional information + +Other information that can be used to further reproduce or isolate the problem. +This commonly includes: + +- screenshots +- logs +- theories about what might be going wrong +- workarounds that you used +- links to related bugs, PRs or discussions diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..521b774 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,9 @@ +contact_links: + - name: Question + url: https://github.com/bevyengine/variadics_please/discussions + about: Questions about how to use or contribute belong in Github Discussions. + You can use the search to check if someone already answered your question! + + - name: Community + url: https://discord.gg/bevy + about: If you'd like to converse with members of the `bevyengine` community, join us on discord. There is a channel for development of this crate. diff --git a/.github/ISSUE_TEMPLATE/docs_improvement.md b/.github/ISSUE_TEMPLATE/docs_improvement.md new file mode 100644 index 0000000..e318cb3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/docs_improvement.md @@ -0,0 +1,13 @@ +--- +name: Documentation Improvement +about: Help us write better documentation! +title: '' +labels: C-Documentation, S-Needs-Triage +assignees: '' +--- + +## How can the documentation be improved? + +Provide a link to the documentation and describe how it could be improved. In what ways is it incomplete, incorrect, or misleading? + +If you have suggestions on exactly what the new docs should say, feel free to include them here. Alternatively, make the changes yourself and create a pull request instead. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..0ac1873 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,24 @@ +--- +name: Feature Request +about: Propose a new feature! +title: '' +labels: C-Feature, S-Needs-Triage +assignees: '' +--- + +## What problem does this solve or what need does it fill? + +A description of why this particular feature should be added. + +## What solution would you like? + +The solution you propose for the problem presented. + +## What alternative(s) have you considered? + +Other solutions to solve and/or work around the problem presented. + +## Additional context + +Any other information you would like to add such as related previous work, +screenshots, benchmarks, etc. diff --git a/.github/ISSUE_TEMPLATE/performance_regression.md b/.github/ISSUE_TEMPLATE/performance_regression.md new file mode 100644 index 0000000..972a8a4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/performance_regression.md @@ -0,0 +1,67 @@ +--- +name: Performance Regression +about: Running slowly after upgrading? Report a performance regression. +title: '' +labels: C-Bug, C-Performance, P-Regression, S-Needs-Triage +assignees: '' +--- + +## `variadics_please` version + +Original: `` + +Current: `` + +## Relevant system information + +This section is optional. Remove it if you know that the problem is not platform dependent. + +Rust version you're using: (`cargo --version`) + +```text + +``` + +> Notes: +> +> - Pay attention to the msrv (minimum supported rust version) of `variadics_please`. +> - `nightly` should work, but sometimes there are regressions: please let us know! + +Operating system, including version: + +```text + +``` + +## What's performing poorly? + +Describe how you arrived at the problem. If you can, consider providing a code snippet or link +to help reproduce the regression. + +If the exact scenario is not immediately reproducible on `cargo run`, please include a set list of steps to produce the correct setup. + +## Before and After Traces + +To best help us investigate the regression, it's best to provide as much detailed profiling +data as possible. + +If your app is running slowly, please show profiler traces before and after the change. +For more information on how to get these traces, see +. + +If this is about a compile-time regression, please provide the full output of `cargo build --timings`, +for more information see . + +- Before: +- After: + +## Additional information + +Other information that can be used to further reproduce or isolate the problem. +This commonly includes: + +- screenshots +- logs +- theories about what might be going wrong +- workarounds that you used +- links to related bugs, PRs or discussions diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..72fbf07 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,14 @@ +version: 2 +updates: + - package-ecosystem: cargo + directory: / + schedule: + interval: weekly + labels: + - "C-Dependencies" + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + labels: + - "C-Dependencies" diff --git a/.github/example-run/all_tuples.ron b/.github/example-run/all_tuples.ron new file mode 100644 index 0000000..72873dd --- /dev/null +++ b/.github/example-run/all_tuples.ron @@ -0,0 +1,2 @@ +( +) diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml new file mode 100644 index 0000000..6976a23 --- /dev/null +++ b/.github/linters/.markdown-lint.yml @@ -0,0 +1,9 @@ +{ + "MD013": false, + "no-inline-html": { + "allowed_elements": [ + "details", + "summary" + ] + } +} \ No newline at end of file diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..475c4f4 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,42 @@ +# Objective + +Describe the objective or issue this PR addresses. + +If you're fixing a specific issue, simply say "Fixes #X". + +## Solution + +Describe the solution used to achieve the objective above. + +## Testing + +- Did you test these changes? If so, how? +- Are there any parts that need more testing? +- How can other people (reviewers) test your changes? Is there anything specific they need to know? +- If relevant, what platforms did you test these changes on, and are there any important ones you can't test? + +## Showcase + +This section is optional. If this PR does not include a visual change or does not add a new feature, you can delete this section. + +- Help others understand the result of this PR by showcasing your awesome work! +- If this PR adds a new feature or public API, consider adding a brief pseudo-code snippet of it in action +- If this PR includes a visual change, consider adding a screenshot, GIF, or video + - If you want, you could even include a before/after comparison! +- If the Migration Guide adequately covers the changes, you can delete this section + +While a showcase should aim to be brief and digestible, you can use a toggleable section to save space on longer showcases: + +```rust +println!("My super cool code."); +``` + + + +## Migration Guide + +> This section is optional. If there are no breaking changes, you can delete this section. + +- If this PR is a breaking change (relative to the last release), describe how a user might need to migrate their code to support these changes +- Simply adding new functionality is not a breaking change. +- Fixing behavior that was definitely a bug, rather than a questionable design choice is not a breaking change. diff --git a/.github/workflows copy/ci.yml b/.github/workflows copy/ci.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/action-on-PR-labeled.yml b/.github/workflows/action-on-PR-labeled.yml new file mode 100644 index 0000000..bf2d71e --- /dev/null +++ b/.github/workflows/action-on-PR-labeled.yml @@ -0,0 +1,30 @@ +name: Action on PR labeled + +# This workflow has write permissions on the repo +# It must not checkout a PR and run untrusted code + +on: + pull_request_target: + types: + - labeled + +permissions: + pull-requests: 'write' + +jobs: + comment-on-breaking-change-label: + runs-on: ubuntu-latest + if: github.event.label.name == 'M-Needs-Migration-Guide' && !contains(github.event.pull_request.body, '## Migration Guide') + steps: + - uses: actions/github-script@v7 + with: + script: | + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `It looks like your PR is a breaking change, but you didn't provide a migration guide. + + Could you add some context on what users should update when this change get released? + Putting it after a \`## Migration Guide\` will help it get automatically picked up by our tooling.` + }) diff --git a/.github/workflows/ci-comment-failures.yml b/.github/workflows/ci-comment-failures.yml new file mode 100644 index 0000000..6c6d75a --- /dev/null +++ b/.github/workflows/ci-comment-failures.yml @@ -0,0 +1,172 @@ +name: CI - PR Comments + + # This workflow has write permissions on the repo + # It must not checkout a PR and run untrusted code + +# Also requesting write permissions on PR to be able to comment +permissions: + pull-requests: 'write' + +on: + workflow_run: + workflows: ["CI"] + types: + - completed + +jobs: + + missing-examples: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'failure' + steps: + - name: 'Download artifact' + id: find-artifact + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ github.event.workflow_run.id }}, + }); + var matchArtifacts = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "missing-examples" + }); + if (matchArtifacts.length == 0) { return "false" } + var matchArtifact = matchArtifacts[0]; + var download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/missing-examples.zip', Buffer.from(download.data)); + return "true" + - run: unzip missing-examples.zip + if: ${{ steps.find-artifact.outputs.result == 'true' }} + - name: 'Comment on PR' + if: ${{ steps.find-artifact.outputs.result == 'true' }} + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var fs = require('fs'); + var issue_number = Number(fs.readFileSync('./NR')); + if (fs.existsSync('./missing-metadata')) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: 'You added a new example but didn\'t add metadata for it. Please update the root Cargo.toml file.' + }); + } + if (fs.existsSync('./missing-update')) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: 'The generated `examples/README.md` is out of sync with the example metadata in `Cargo.toml` or the example readme template. Please run `cargo run -p build-templated-pages -- update examples` to update it, and commit the file change.' + }); + } + + missing-features: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'failure' + steps: + - name: 'Download artifact' + id: find-artifact + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ github.event.workflow_run.id }}, + }); + var matchArtifacts = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "missing-features" + }); + if (matchArtifacts.length == 0) { return "false" } + var matchArtifact = matchArtifacts[0]; + var download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/missing-features.zip', Buffer.from(download.data)); + return "true" + - run: unzip missing-features.zip + if: ${{ steps.find-artifact.outputs.result == 'true' }} + - name: 'Comment on PR' + if: ${{ steps.find-artifact.outputs.result == 'true' }} + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var fs = require('fs'); + var issue_number = Number(fs.readFileSync('./NR')); + if (fs.existsSync('./missing-features')) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: 'You added a new feature but didn\'t add a description for it. Please update the root Cargo.toml file.' + }); + } + + msrv: + runs-on: ubuntu-latest + if: > + github.event.workflow_run.event == 'pull_request' && + github.event.workflow_run.conclusion == 'failure' + steps: + - name: 'Download artifact' + id: find-artifact + uses: actions/github-script@v7 + with: + result-encoding: string + script: | + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: ${{ github.event.workflow_run.id }}, + }); + var matchArtifacts = artifacts.data.artifacts.filter((artifact) => { + return artifact.name == "msrv" + }); + if (matchArtifacts.length == 0) { return "false" } + var matchArtifact = matchArtifacts[0]; + var download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + var fs = require('fs'); + fs.writeFileSync('${{github.workspace}}/msrv.zip', Buffer.from(download.data)); + return "true" + - run: unzip msrv.zip + if: ${{ steps.find-artifact.outputs.result == 'true' }} + - name: 'Comment on PR' + if: ${{ steps.find-artifact.outputs.result == 'true' }} + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + var fs = require('fs'); + var issue_number = Number(fs.readFileSync('./NR')); + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: 'Your PR increases the Minimum Supported Rust Version (`msrv`). Please update the `rust-version` field in ``Cargo.toml.' + }); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26e1f1f..28a2d22 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,38 +1,412 @@ name: Continuous integration on: - push: + merge_group: pull_request: - branches: [main] + push: + branches: + - main + - release-* + +env: + CARGO_TERM_COLOR: always + # If nightly is breaking CI, modify this variable to target a specific nightly version. + NIGHTLY_TOOLCHAIN: nightly + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: ${{github.event_name == 'pull_request'}} jobs: - test: - name: Test Suite - runs-on: ubuntu-latest + build: + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 30 steps: - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable - - name: Test - run: cargo test + - name: Build & run tests + run: cargo test --workspace --lib --bins --tests --benches + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-C debuginfo=0 -D warnings" - fmt: - name: Rustfmt + lint: runs-on: ubuntu-latest + timeout-minutes: 30 steps: - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-ci-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable with: - components: rustfmt - - name: Format + components: rustfmt, clippy + - name: Check formatting run: cargo fmt --all -- --check + - name: Clippy + run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings + + miri: + # Explicitly use macOS 14 to take advantage of M1 chip. + runs-on: macos-14 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-miri-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} + components: miri + - name: CI job + run: cargo miri test -p variadics_please + env: + RUSTFLAGS: -Zrandomize-layout - clippy: - name: Clippy + check-compiles: runs-on: ubuntu-latest + timeout-minutes: 30 + needs: lint steps: - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-check-compiles-${{ hashFiles('**/Cargo.toml') }} - uses: dtolnay/rust-toolchain@stable with: - components: clippy - - name: Clippy - run: cargo clippy -- -D warnings + toolchain: stable + - name: Check Compile + run: | + cargo test --target-dir ../../../target + cargo check --benches --target-dir ../target --manifest-path ./benches/Cargo.toml + cargo check --workspace --examples + cargo check --workspace + cargo check --workspace --tests + + check-compiles-no-std: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: lint + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-check-compiles-no-std-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@stable + with: + targets: x86_64-unknown-none + - name: Check Compile + run: cargo check --no-default-features + + build-wasm: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: build + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ubuntu-assets-cargo-build-wasm-stable-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@stable + with: + target: wasm32-unknown-unknown + - name: Check wasm + run: cargo check --target wasm32-unknown-unknown + + build-wasm-atomics: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: build + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ubuntu-assets-cargo-build-wasm-nightly-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} + targets: wasm32-unknown-unknown + components: rust-src + - name: Check wasm + run: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort + env: + RUSTFLAGS: "-C target-feature=+atomics,+bulk-memory" + + markdownlint: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: check-missing-features-in-docs + if: always() + steps: + - uses: actions/checkout@v4 + with: + # Full git history is needed to get a proper list of changed files within `super-linter` + fetch-depth: 0 + - name: Run Markdown Lint + uses: docker://ghcr.io/github/super-linter:slim-v4 + env: + MULTI_STATUS: false + VALIDATE_ALL_CODEBASE: false + VALIDATE_MARKDOWN: true + DEFAULT_BRANCH: main + + toml: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install taplo + run: cargo install taplo-cli --locked + - name: Run Taplo + id: taplo + run: taplo fmt --check --diff + - name: Taplo info + if: failure() + run: | + echo 'To fix toml fmt, please run `taplo fmt`' + echo 'To check for a diff, run `taplo fmt --check --diff' + echo 'You can find taplo here: https://taplo.tamasfe.dev/' + echo 'Or if you use VSCode, use the `Even Better Toml` extension' + echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml' + + typos: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Check for typos + uses: crate-ci/typos@v1.27.0 + - name: Typos info + if: failure() + run: | + echo 'To fix typos, please run `typos -w`' + echo 'To check for a diff, run `typos`' + echo 'You can find typos here: https://crates.io/crates/typos' + echo 'if you use VSCode, you can also install `Typos Spell Checker' + echo 'You can find the extension here: https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode' + + run-examples-macos-metal: + # Explicitly use macOS 14 to take advantage of M1 chip. + runs-on: macos-14 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Disable audio + # Disable audio through a patch. on github m1 runners, audio timeouts after 15 minutes + run: git apply --ignore-whitespace tools/example-showcase/disable-audio.patch + - name: Build + # this uses the same command as when running the example to ensure build is reused + run: | + TRACE_CHROME=trace-all_tuples.json CI_TESTING_CONFIG=.github/example-run/all_tuples.ron cargo build --example all_tuples + - name: Run examples + run: | + for example in .github/example-run/*.ron; do + example_name=`basename $example .ron` + echo -n $example_name > last_example_run + echo "running $example_name - "`date` + time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example cargo run --example $example_name + sleep 10 + done + mkdir traces && mv trace*.json traces/ + - name: Save traces + uses: actions/upload-artifact@v4 + with: + name: example-traces-macos + path: traces + - name: Save PR number + if: ${{ github.event_name == 'pull_request' }} + run: | + echo ${{ github.event.number }} > ./screenshots/PR + - uses: actions/upload-artifact@v4 + if: ${{ failure() && github.event_name == 'pull_request' }} + with: + name: example-run-macos + path: example-run/ + + check-doc: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-check-doc-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} + - name: Build doc + run: cargo doc --workspace --all-features --no-deps --document-private-items --keep-going + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-C debuginfo=0 --cfg docsrs_dep" + - name: Check doc + run: cargo test --workspace --doc + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-C debuginfo=0 --cfg docsrs_dep" + - name: Installs cargo-deadlinks + run: cargo install --force cargo-deadlinks + - name: Checks dead links + run: cargo deadlinks --dir target/documentation + continue-on-error: true + + check-missing-examples-in-docs: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: check for missing metadata + id: missing-metadata + run: cargo run -p build-templated-pages -- check-missing examples + - name: check for missing update + run: cargo run -p build-templated-pages -- update examples + - name: Check for modified files + id: missing-update + run: | + echo "if this step fails, run the following command and commit the changed file on your PR." + echo " > cargo run -p build-templated-pages -- update examples" + git diff --quiet HEAD -- + - name: Save PR number + if: ${{ failure() && github.event_name == 'pull_request' }} + run: | + mkdir -p ./missing-examples + echo ${{ github.event.number }} > ./missing-examples/NR + - name: log failed task - missing metadata + if: ${{ failure() && github.event_name == 'pull_request' && steps.missing-metadata.conclusion == 'failure' }} + run: touch ./missing-examples/missing-metadata + - name: log failed task - missing update + if: ${{ failure() && github.event_name == 'pull_request' && steps.missing-update.conclusion == 'failure' }} + run: touch ./missing-examples/missing-update + - uses: actions/upload-artifact@v4 + if: ${{ failure() && github.event_name == 'pull_request' }} + with: + name: missing-examples + path: missing-examples/ + + check-missing-features-in-docs: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: check-missing-examples-in-docs + steps: + - uses: actions/checkout@v4 + - name: check for missing features + id: missing-features + run: cargo run -p build-templated-pages -- check-missing features + - name: check for missing update + run: cargo run -p build-templated-pages -- update features + - name: Check for modified files + id: missing-update + run: | + echo "if this step fails, run the following command and commit the changed file on your PR." + echo " > cargo run -p build-templated-pages -- update features" + git diff --quiet HEAD -- + - name: Save PR number + if: ${{ failure() && github.event_name == 'pull_request' }} + run: | + mkdir -p ./missing-features + echo ${{ github.event.number }} > ./missing-features/NR + - name: log failed task - missing features + if: ${{ failure() && github.event_name == 'pull_request' && steps.missing-features.conclusion == 'failure' }} + run: touch ./missing-features/missing-features + - name: log failed task - missing update + if: ${{ failure() && github.event_name == 'pull_request' && steps.missing-update.conclusion == 'failure' }} + run: touch ./missing-features/missing-update + - uses: actions/upload-artifact@v4 + if: ${{ failure() && github.event_name == 'pull_request' }} + with: + name: missing-features + path: missing-features/ + + msrv: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: build + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-msrv-${{ hashFiles('**/Cargo.toml') }} + - name: get MSRV + id: msrv + run: | + msrv=`cargo metadata --no-deps --format-version 1 | jq --raw-output '.packages[] | select(.name=="variadics_please") | .rust_version'` + echo "msrv=$msrv" >> $GITHUB_OUTPUT + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ steps.msrv.outputs.msrv }} + - name: Run cargo check + id: check + run: cargo check + - name: Save PR number + if: ${{ failure() && github.event_name == 'pull_request' && steps.check.conclusion == 'failure' }} + run: | + mkdir -p ./msrv + echo ${{ github.event.number }} > ./msrv/NR + - uses: actions/upload-artifact@v4 + if: ${{ failure() && github.event_name == 'pull_request' && steps.check.conclusion == 'failure' }} + with: + name: msrv + path: msrv/ diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml new file mode 100644 index 0000000..ceb0f42 --- /dev/null +++ b/.github/workflows/dependencies.yml @@ -0,0 +1,61 @@ +name: Dependencies + +on: + pull_request: + paths: + - '**/Cargo.toml' + - 'deny.toml' + push: + paths: + - '**/Cargo.toml' + - 'deny.toml' + branches: + - main + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: ${{github.event_name == 'pull_request'}} + +env: + CARGO_TERM_COLOR: always + +jobs: + check-advisories: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install cargo-deny + run: cargo install cargo-deny + - name: Check for security advisories and unmaintained crates + run: cargo deny check advisories + + check-bans: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install cargo-deny + run: cargo install cargo-deny + - name: Check for banned and duplicated dependencies + run: cargo deny check bans + + check-licenses: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install cargo-deny + run: cargo install cargo-deny + - name: Check for unauthorized licenses + run: cargo deny check licenses + + check-sources: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install cargo-deny + run: cargo install cargo-deny + - name: Checked for unauthorized crate sources + run: cargo deny check sources diff --git a/.github/workflows/post-release.yml b/.github/workflows/post-release.yml new file mode 100644 index 0000000..82c26a3 --- /dev/null +++ b/.github/workflows/post-release.yml @@ -0,0 +1,56 @@ +name: Post-release version bump + +# how to trigger: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow +on: + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + ci: + if: github.repository == 'bevyengine/variadics_please' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install cargo-release + run: cargo install cargo-release + + - name: Setup post-release version bump + run: | + # Set the commit author to the github-actions bot. See discussion here for more information: + # https://github.com/actions/checkout/issues/13#issuecomment-724415212 + # https://github.uint.cloudmunity/t/github-actions-bot-email-address/17204/6 + git config user.name 'Auto Releaser' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + # Read the current version from Cargo.toml + current_version=$(cargo metadata --format-version 1 --no-deps | \ + jq --raw-output '.packages | .[] | select(.name == "variadics_please").version') + # Sanity check: current version should be 0.X.Y-dev + if ! grep -q '^0\.[0-9]\+\.[0-9]\+-dev$' <<< "${current_version}"; then + echo "Invalid version (not in 0.X.Y-dev format): ${current_version}" + exit 1 + fi + minor_version=$(sed 's/^0\.\([0-9]\+\).*/\1/' <<< "${current_version}") + next_version=0.$((minor_version + 1)).0-dev + echo "Bumping version to ${next_version}" + # See release.yml for meaning of these arguments + cargo release "${next_version}" \ + --workspace \ + --no-publish \ + --execute \ + --no-tag \ + --no-confirm \ + --no-push \ + --exclude errors \ + + - name: Create PR + uses: peter-evans/create-pull-request@v7 + with: + delete-branch: true + base: "main" + title: "Bump Version after Release" + body: | + Bump version after release + This PR has been auto-generated diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..8844c82 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Release + +# how to trigger: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow +on: + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + ci: + if: github.repository == 'bevyengine/variadics_please' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install cargo-release + run: cargo install cargo-release + + - name: Setup release + run: | + # Set the commit author to the github-actions bot. See discussion here for more information: + # https://github.com/actions/checkout/issues/13#issuecomment-724415212 + # https://github.uint.cloudmunity/t/github-actions-bot-email-address/17204/6 + git config user.name 'Bevy Auto Releaser' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + # release: remove the dev suffix, like going from 0.X.0-dev to 0.X.0 + # --workspace: updating all crates in the workspace + # --no-publish: do not publish to crates.io + # --execute: not a dry run + # --no-tag: do not push tag for each new version + # --no-push: do not push the update commits + # --dependent-version upgrade: change 0.X.0-dev in internal dependencies to 0.X.0 + # --exclude: ignore those packages + cargo release release \ + --workspace \ + --no-publish \ + --execute \ + --no-tag \ + --no-confirm \ + --no-push \ + --dependent-version upgrade \ + --exclude ci \ + --exclude errors \ + + - name: Create PR + uses: peter-evans/create-pull-request@v7 + with: + delete-branch: true + base: "main" + title: "Preparing Next Release" + body: | + Preparing next release. This PR has been auto-generated. diff --git a/.github/workflows/send-screenshots-to-pixeleagle.yml b/.github/workflows/send-screenshots-to-pixeleagle.yml new file mode 100644 index 0000000..2f15774 --- /dev/null +++ b/.github/workflows/send-screenshots-to-pixeleagle.yml @@ -0,0 +1,94 @@ +name: Send Screenshots to Pixel Eagle + +on: + workflow_call: + inputs: + artifact: + required: true + type: string + commit: + required: true + type: string + branch: + required: true + type: string + os: + required: true + type: string + +jobs: + send-to-pixel-eagle: + name: Send screenshots to Pixel Eagle + runs-on: ubuntu-24.04 + steps: + + - name: Download artifact + uses: actions/download-artifact@v4 + with: + pattern: ${{ inputs.artifact }} + + - name: Send to Pixel Eagle + env: + project: B04F67C0-C054-4A6F-92EC-F599FEC2FD1D + run: | + # Create a new run with its associated metadata + metadata='{"os":"${{ inputs.os }}", "commit": "${{ inputs.commit }}", "branch": "${{ inputs.branch }}"}' + run=`curl https://pixel-eagle.vleue.com/$project/runs --json "$metadata" --oauth2-bearer ${{ secrets.PIXELEAGLE_TOKEN }} | jq '.id'` + + SAVEIFS=$IFS + + cd ${{ inputs.artifact }} + + # Read the hashes of the screenshot for fast comparison when they are equal + IFS=$'\n' + # Build a json array of screenshots and their hashes + hashes='['; + for screenshot in $(find . -type f -name "*.png"); + do + name=${screenshot:14} + echo $name + hash=`shasum -a 256 $screenshot | awk '{print $1}'` + hashes="$hashes [\"$name\",\"$hash\"]," + done + hashes=`echo $hashes | rev | cut -c 2- | rev` + hashes="$hashes]" + + IFS=$SAVEIFS + + # Upload screenshots with unknown hashes + curl https://pixel-eagle.vleue.com/$project/runs/$run/hashes --json "$hashes" --oauth2-bearer ${{ secrets.PIXELEAGLE_TOKEN }} | jq '.[]|[.name] | @tsv' | + while IFS=$'\t' read -r name; do + name=`echo $name | tr -d '"'` + echo "Uploading $name" + curl https://pixel-eagle.vleue.com/$project/runs/$run/screenshots -F "data=@./screenshots-$name" -F "screenshot=$name" --oauth2-bearer ${{ secrets.PIXELEAGLE_TOKEN }} + echo + done + + IFS=$SAVEIFS + + cd .. + + # Trigger comparison with the main branch on the same os + curl https://pixel-eagle.vleue.com/$project/runs/$run/compare/auto --json '{"os":"", "branch": "main"}' --oauth2-bearer ${{ secrets.PIXELEAGLE_TOKEN }} > pixeleagle.json + + # Log results + compared_with=`cat pixeleagle.json | jq '.to'` + + status=0 + missing=`cat pixeleagle.json | jq '.missing | length'` + if [ ! $missing -eq 0 ]; then + echo "There are $missing missing screenshots" + echo "::warning title=$missing missing screenshots on ${{ inputs.os }}::https://pixel-eagle.vleue.com/$project/runs/$run/compare/$compared_with" + status=1 + fi + + diff=`cat pixeleagle.json | jq '.diff | length'` + if [ ! $diff -eq 0 ]; then + echo "There are $diff screenshots with a difference" + echo "::warning title=$diff different screenshots on ${{ inputs.os }}::https://pixel-eagle.vleue.com/$project/runs/$run/compare/$compared_with" + status=1 + fi + + echo "created run $run: https://pixel-eagle.vleue.com/$project/runs/$run/compare/$compared_with" + + exit $status diff --git a/.github/workflows/validation-jobs.yml b/.github/workflows/validation-jobs.yml new file mode 100644 index 0000000..f886ea3 --- /dev/null +++ b/.github/workflows/validation-jobs.yml @@ -0,0 +1,234 @@ +name: validation jobs + +on: + merge_group: + pull_request: + push: + branches: + - main + - release-* + +concurrency: + group: ${{github.workflow}}-${{github.ref}} + cancel-in-progress: ${{github.event_name == 'pull_request'}} + +env: + CARGO_TERM_COLOR: always + # If nightly is breaking CI, modify this variable to target a specific nightly version. + NIGHTLY_TOOLCHAIN: nightly + +jobs: + build-and-install-on-iOS: + if: ${{ github.event_name == 'merge_group' }} + runs-on: macos-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: actions/cache@v4 + with: + path: | + target + key: ${{ runner.os }}-ios-install-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.lock') }} + # TODO: remove x86 target once it always run on arm GitHub runners + - name: Add iOS targets + run: rustup target add aarch64-apple-ios x86_64-apple-ios aarch64-apple-ios-sim + - name: Build and install iOS app in iOS Simulator. + run: cd examples/mobile && make install + + build-android: + if: ${{ github.event_name == 'merge_group' }} + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-build-android-${{ hashFiles('**/Cargo.toml') }} + + run-examples-linux: + # also run when pushed to main to update reference screenshots + if: ${{ github.event_name != 'pull_request' }} + runs-on: ubuntu-22.04 + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - name: Build + # this uses the same command as when running the example to ensure build is reused + run: | + TRACE_CHROME=trace-all_tuples.json CI_TESTING_CONFIG=.github/example-run/all_tuples.ron cargo build --example all_tuples + - name: Run examples + run: | + for example in .github/example-run/*.ron; do + example_name=`basename $example .ron` + echo -n $example_name > last_example_run + echo "running $example_name - "`date` + time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example cargo run --example $example_name + sleep 10 + done + mkdir traces && mv trace*.json traces/ + - name: save traces + uses: actions/upload-artifact@v4 + with: + name: example-traces-linux + path: traces + - uses: actions/upload-artifact@v4 + if: ${{ failure() && github.event_name == 'pull_request' }} + with: + name: example-run-linux + path: example-run/ + + run-examples-on-windows-dx12: + if: ${{ github.event_name != 'pull_request' }} + runs-on: windows-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Build + shell: bash + # this uses the same command as when running the example to ensure build is reused + run: | + TRACE_CHROME=trace-all_tuples.json CI_TESTING_CONFIG=.github/example-run/all_tuples.ron cargo build --example all_tuples + - name: Run examples + shell: bash + run: | + for example in .github/example-run/*.ron; do + example_name=`basename $example .ron` + echo -n $example_name > last_example_run + echo "running $example_name - "`date` + time TRACE_CHROME=trace-$example_name.json CI_TESTING_CONFIG=$example cargo run --example $example_name + sleep 10 + done + mkdir traces && mv trace*.json traces/ + - name: save traces + uses: actions/upload-artifact@v4 + with: + name: example-traces-windows + path: traces + - uses: actions/upload-artifact@v4 + if: ${{ failure() && github.event_name == 'pull_request' }} + with: + name: example-run-windows + path: example-run/ + + run-examples-on-wasm: + if: ${{ github.event_name == 'merge_group' }} + runs-on: ubuntu-22.04 + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + with: + target: wasm32-unknown-unknown + + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ~/.github/start-wasm-example/node_modules + target/ + key: ${{ runner.os }}-wasm-run-examples-${{ hashFiles('**/Cargo.toml') }} + + - name: install xvfb, llvmpipe and lavapipe + run: | + sudo apt-get update -y -qq + sudo add-apt-repository ppa:kisak/turtle -y + sudo apt-get update + sudo apt install -y xvfb libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers + + - name: Install wasm-bindgen + run: cargo install --force wasm-bindgen-cli + + - name: Setup playwright + run: | + cd .github/start-wasm-example + npm install + npx playwright install --with-deps + cd ../.. + + - name: First Wasm build + run: | + cargo build --release --example testbed_ui --target wasm32-unknown-unknown + + - name: Run examples + shell: bash + run: | + # start a webserver + python3 -m http.server --directory examples/wasm & + + xvfb-run cargo run -p build-wasm-example -- --browsers chromium --browsers firefox --frames 25 --test 2d_shapes lighting text_debug breakout + + - name: Save screenshots + uses: actions/upload-artifact@v4 + with: + name: screenshots-wasm + path: .github/start-wasm-example/screenshot-*.png + + build-without-default-features: + if: ${{ github.event_name == 'merge_group' }} + timeout-minutes: 30 + strategy: + max-parallel: 1 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Build + run: cargo build --no-default-features + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-C debuginfo=0 -D warnings" + + build-without-default-features-status: + if: | + always() && + github.event_name == 'merge_group' + needs: build-without-default-features + runs-on: ubuntu-latest + steps: + - name: Successful + if: ${{ !(contains(needs.*.result, 'failure')) }} + run: exit 0 + - name: Failing + if: ${{ contains(needs.*.result, 'failure') }} + run: exit 1 + + check-unused-dependencies: + if: ${{ github.event_name == 'merge_group' }} + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-check-unused-dependencies-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ env.NIGHTLY_TOOLCHAIN }} + - name: Installs cargo-udeps + run: cargo install --force cargo-udeps + - name: Run cargo udeps + run: cargo udeps diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml new file mode 100644 index 0000000..cf8ff1a --- /dev/null +++ b/.github/workflows/weekly.yml @@ -0,0 +1,111 @@ +name: Weekly beta compile test + +on: + schedule: + # New versions of rust release on Thursdays. We test on Mondays to get at least 3 days of warning before all our CI breaks again. + # https://forge.rust-lang.org/release/process.html#release-day-thursday + - cron: '0 12 * * 1' + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +jobs: + test: + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@beta + - name: Install Linux dependencies + run: cargo test --workspace --lib --bins --tests --benches + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-C debuginfo=0 -D warnings" + + lint: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@beta + with: + components: rustfmt, clippy + - name: Check formatting + run: cargo fmt --all -- --check + - name: Clippy + run: cargo clippy --workspace --all-targets --all-features -- -Dwarnings + + check-compiles: + runs-on: ubuntu-latest + timeout-minutes: 30 + needs: test + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-check-compiles-${{ hashFiles('**/Cargo.toml') }} + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + - name: Check Compile + run: | + cargo test --target-dir ../../../target + cargo check --benches --target-dir ../target --manifest-path ./benches/Cargo.toml + cargo check --workspace --examples + cargo check --workspace + cargo check --workspace --tests + + check-doc: + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@beta + - name: Build and check docs + run: cargo run -p ci -- doc + env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: "-C debuginfo=0 --cfg docsrs_dep" + + open-issue: + name: Warn that weekly CI fails + runs-on: ubuntu-latest + needs: [test, lint, check-compiles, check-doc] + permissions: + issues: write + # Use always() so the job doesn't get canceled if any other jobs fail + if: ${{ always() && contains(needs.*.result, 'failure') }} + steps: + - name: Create issue + run: | + previous_issue_number=$(gh issue list \ + --search "$TITLE in:title" \ + --json number \ + --jq '.[0].number') + if [[ -n $previous_issue_number ]]; then + gh issue comment $previous_issue_number \ + --body "Weekly pipeline still fails: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" + else + gh issue create \ + --title "$TITLE" \ + --label "$LABELS" \ + --body "$BODY" + fi + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: ${{ github.repository }} + TITLE: Main branch fails to compile on Rust beta. + LABELS: C-Bug,S-Needs-Triage + BODY: | + ## Weekly CI run has failed. + [The offending run.](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) diff --git a/.github/workflows/welcome.yml b/.github/workflows/welcome.yml new file mode 100644 index 0000000..96a2879 --- /dev/null +++ b/.github/workflows/welcome.yml @@ -0,0 +1,47 @@ +name: Welcome new contributors + +# This workflow has write permissions on the repo +# It must not checkout a PR and run untrusted code + +on: + pull_request_target: + types: + - opened + +jobs: + welcome: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/github-script@v7 + with: + script: | + // Get a list of all issues created by the PR opener + // See: https://octokit.github.io/rest.js/#pagination + const creator = context.payload.sender.login + const opts = github.rest.issues.listForRepo.endpoint.merge({ + ...context.issue, + creator, + state: 'all' + }) + const issues = await github.paginate(opts) + + for (const issue of issues) { + if (issue.number === context.issue.number) { + continue + } + + if (issue.pull_request) { + return // Creator is already a contributor. + } + } + + await github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `**Welcome**, new contributor! + + Please make sure you've read our [contributing guide](https://bevyengine.org/learn/contribute/introduction) and we look forward to reviewing your pull request shortly ✨` + }) diff --git a/.gitignore b/.gitignore index 81f6577..6919713 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,18 @@ -# Generated by Cargo -# will have compiled files and executables -debug/ -target/ - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html -Cargo.lock - -# These are backup files generated by rustfmt +# Rust build artifacts +/target +crates/*/target **/*.rs.bk +/benches/target +/tools/compile_fail_utils/target -# MSVC Windows builds of rustc generate these, which store debugging information -*.pdb +# Cargo +Cargo.lock +.cargo/config +.cargo/config.toml -# RustRover -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ +# IDE files +/.idea +/.vscode +.zed +dxcompiler.dll +dxil.dll diff --git a/Cargo.toml b/Cargo.toml index 6aaa6e7..fadf6d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,11 +3,14 @@ name = "variadics_please" version = "1.0.0" edition = "2021" description = "Implement things as if rust had variadics" -homepage = "https://bevyengine.org" +homepage = "https://github.com/bevyengine/variadics_please" repository = "https://github.com/bevyengine/variadics_please" license = "MIT OR Apache-2.0" keywords = ["bevy", "variadics", "docs"] rust-version = "1.65.0" +categories = ["macros", "utilities"] +exclude = ["tools/", ".github/", "variadics_please/"] +documentation = "https://docs.rs/variadics_please" [features] default = ["alloc"] @@ -21,7 +24,18 @@ syn = "2.0" quote = "1.0" proc-macro2 = "1.0" -[lints.clippy] +[workspace] +exclude = [ + "benches", + "compile_fail", + "tools/compile_fail_utils", +] +members = [ + "errors", + "tools/compile_fail_utils" +] + +[workspace.lints.clippy] doc_markdown = "warn" manual_let_else = "warn" match_same_arms = "warn" @@ -31,25 +45,17 @@ semicolon_if_nothing_returned = "warn" type_complexity = "allow" undocumented_unsafe_blocks = "warn" unwrap_or_default = "warn" - ptr_as_ptr = "warn" ptr_cast_constness = "warn" ref_as_ptr = "warn" - -# see: https://github.com/bevyengine/bevy/pull/15375#issuecomment-2366966219 too_long_first_doc_paragraph = "allow" - std_instead_of_core = "warn" std_instead_of_alloc = "warn" alloc_instead_of_core = "warn" -[lints.rust] +[workspace.lints.rust] missing_docs = "warn" unexpected_cfgs = { level = "warn", check-cfg = ['cfg(docsrs_dep)'] } unsafe_code = "deny" unsafe_op_in_unsafe_fn = "warn" unused_qualifications = "warn" - -[package.metadata.docs.rs] -rustdoc-args = ["-Zunstable-options", "--generate-link-to-definition"] -all-features = true diff --git a/README.md b/README.md index 0790368..77cf841 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +
# `variadics_please` diff --git a/documentation/debugging.md b/documentation/debugging.md new file mode 100644 index 0000000..a704a9d --- /dev/null +++ b/documentation/debugging.md @@ -0,0 +1,8 @@ +# Debugging + +## Macro Debugging + +- Print the final output of a macro using `cargo rustc --profile=check -- -Zunstable-options --pretty=expanded` + - Alternatively you could install and use [cargo expand](https://github.com/dtolnay/cargo-expand) which adds syntax highlighting to the terminal output. + - Additionally get pager by piping to `less` ( on Unix systems ): `cargo expand --color always | less -R` +- Print output during macro compilation using `eprintln!("hi");` diff --git a/documentation/linters.md b/documentation/linters.md new file mode 100644 index 0000000..d53a4c5 --- /dev/null +++ b/documentation/linters.md @@ -0,0 +1,47 @@ +# Linters in this Repository + +## Code Format Linting with [rustfmt](https://github.com/rust-lang/rustfmt) + +Can be automatically validated with [`cargo run -p ci`](../tools/ci) (which also runs other checks). Running this command will actually format the code: + +```bash +cargo fmt --all +``` + +## Code Linting with [Clippy](https://github.com/rust-lang/rust-clippy) + +Can be automatically run with [`cargo run -p ci`](../tools/ci) (which also runs other checks) or manually with this command: + +```bash +cargo clippy --workspace --all-targets --all-features -- -D warnings +``` + +Explanation: + +* `-D warnings`: No warnings are allowed in the codebase. + +## [super-linter](https://github.com/github/super-linter) + +`super-linter` provides easy access to many different Linters. + +### [markdownlint](https://github.com/DavidAnson/markdownlint) + +`markdownlint` is provided by `super-linter` and is responsible for `.md` files. +Its configuration is saved in the [.markdown-lint.yml](../.github/linters/.markdown-lint.yml) file. + +The provided rules are documented [here](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md) and information about setting the config can be seen [here](https://github.com/DavidAnson/markdownlint#optionsconfig). + +#### Using [VS Code markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint) + +If you want to use the VS Code Extension with the rules defined in [.markdown-lint.yml](../.github/linters/.markdown-lint.yml), then you need to create a local config file in the root of the project with the configuration below. +Currently, this is not needed as the extension already disables the rule `MD013` by default. + +```json +{ + "extends": ".github/linters/.markdown-lint.yml" +} +``` + +### Other Linters provided by [super-linter](https://github.com/github/super-linter) + +All other linters not mentioned in the this file are not activated and can be seen [here](https://github.com/github/super-linter#supported-linters). diff --git a/errors/Cargo.toml b/errors/Cargo.toml new file mode 100644 index 0000000..a7bbed4 --- /dev/null +++ b/errors/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "errors" +edition = "2021" +description = "Documentation and tests for error codes" +publish = false +license = "MIT OR Apache-2.0" + +[dependencies] +variadics_please = { path = ".." } + +[lints] +workspace = true diff --git a/errors/README.md b/errors/README.md new file mode 100644 index 0000000..735c5aa --- /dev/null +++ b/errors/README.md @@ -0,0 +1,3 @@ +# Error Codes + +This crate lists and tests explanations and examples of the error codes. diff --git a/errors/V0001.md b/errors/V0001.md new file mode 100644 index 0000000..80dfddb --- /dev/null +++ b/errors/V0001.md @@ -0,0 +1,3 @@ +# V0001 + +Placeholder diff --git a/errors/src/lib.rs b/errors/src/lib.rs new file mode 100644 index 0000000..590b3c9 --- /dev/null +++ b/errors/src/lib.rs @@ -0,0 +1,4 @@ +//! Definitions of `variadics_please`'s error codes that might occur at runtime. + +#[doc = include_str!("../V0001.md")] +pub struct V0001; diff --git a/tools/compile_fail_utils/Cargo.toml b/tools/compile_fail_utils/Cargo.toml new file mode 100644 index 0000000..126355b --- /dev/null +++ b/tools/compile_fail_utils/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "compile_fail_utils" +edition = "2021" +description = "Utilities for compile tests" +homepage = "https://github.com/bevyengine/variadics_please" +repository = "https://github.com/bevyengine/variadics_please" +license = "MIT OR Apache-2.0" +publish = false + +[dependencies] +ui_test = "0.23.0" + +[[test]] +name = "example" +harness = false diff --git a/tools/compile_fail_utils/README.md b/tools/compile_fail_utils/README.md new file mode 100644 index 0000000..affc7e7 --- /dev/null +++ b/tools/compile_fail_utils/README.md @@ -0,0 +1,30 @@ +# Helpers for compile fail tests + +This crate contains everything needed to set up compile tests for this repository. It, like all compile test crates, is excluded from the workspace. This is done to not fail [`crater` tests](https://github.com/rust-lang/crater). The `CI` workflow executes these tests on the stable rust toolchain see ([tools/ci](../../tools/ci/src/main.rs)). + +## Writing new test cases + +Test cases are annotated .rs files. These annotations define how the test case should be run and what we're expecting to fail. Please see for more information. + +Annotations can roughly be split into global annotations which are prefixed with `//@` and define how tests should be run and error annotations which are prefixed with `//~` and define where errors we expect to happen. From the global annotations, you're only likely to care about `//@check-pass` which will make any compile errors in the test trigger a test failure. + +The error annotations are composed of two parts. +An optional location specifier: + +- `^` The error happens on the line above. +- `v` The error happens on the line below. +- `|` The error annotation is connected to another one. +- If the location specifier is missing, the error is assumed to happen on the same line as the annotation. + +An error matcher: + +- `E####` The error we're expecting has the [`####` rustc error code](https://doc.rust-lang.org/error_codes/error-index.html), e.g `E0499` +- `` The given [compiler lint](https://doc.rust-lang.org/rustc/lints/index.html) is triggered, e.g. `dead_code` +- `LEVEL: ` A compiler error of the given level (valid levels are: `ERROR`, `HELP`, `WARN` or `NOTE`) will be raised and it will contain the `substring`. Substrings can contain spaces. +- `LEVEL: //` Same as above but a regex is used to match the error message. + +An example of an error annotation would be `//~v ERROR: missing trait`. This error annotation will match any error occurring on the line below that contains the substring `missing trait`. + +## A note about `.stderr` files + +We're capable of generating `.stderr` files for all our compile tests. These files contain the error output generated by the test. To create or regenerate them yourself, trigger the tests with the `BLESS` environment variable set to any value (e.g. `BLESS="some symbolic value"`). We currently have to ignore mismatches between these files and the actual stderr output from their corresponding test due to issues with file paths. We attempt to sanitize file paths but for proc-macros, the compiler error messages contain file paths to the current toolchain's copy of the standard library. If we knew of a way to construct a path to the current toolchains folder we could fix this. diff --git a/tools/compile_fail_utils/src/lib.rs b/tools/compile_fail_utils/src/lib.rs new file mode 100644 index 0000000..ff6383c --- /dev/null +++ b/tools/compile_fail_utils/src/lib.rs @@ -0,0 +1,126 @@ +use std::{ + env, + path::{Path, PathBuf}, +}; + +// Re-export ui_test so all the tests use the same version. +pub use ui_test; + +use ui_test::{ + color_eyre::eyre::eyre, + default_file_filter, default_per_file_config, + dependencies::DependencyBuilder, + run_tests_generic, + spanned::Spanned, + status_emitter::{Gha, StatusEmitter, Text}, + Args, Config, OutputConflictHandling, +}; + +/// Use this instead of hand rolling configs. +/// +/// `root_dir` is the directory your tests are contained in. Needs to be a path from crate root. +/// This config will build dependencies and will assume that the cargo manifest is placed at the +/// current working directory. +fn basic_config(root_dir: impl Into, args: &Args) -> ui_test::Result { + let root_dir = root_dir.into(); + + match root_dir.try_exists() { + Ok(true) => { /* success */ } + Ok(false) => { + return Err(eyre!("path does not exist: {:?}", root_dir)); + } + Err(error) => { + return Err(eyre!("failed to read path: {:?} ({:?})", root_dir, error)); + } + } + + let mut config = Config { + bless_command: Some( + "`cargo test` with the BLESS environment variable set to any non empty value" + .to_string(), + ), + output_conflict_handling: if env::var_os("BLESS").is_some() { + OutputConflictHandling::Bless + } else { + // stderr output changes between rust versions so we just rely on annotations + OutputConflictHandling::Ignore + }, + ..Config::rustc(root_dir) + }; + + config.with_args(args); + + let bevy_root = ".."; + + // Don't leak contributor filesystem paths + config.path_stderr_filter(Path::new(bevy_root), b"$BEVY_ROOT"); + config.path_stderr_filter(Path::new(env!("RUSTUP_HOME")), b"$RUSTUP_HOME"); + + // ui_test doesn't compile regex with perl character classes. + // \pL = unicode class for letters, \pN = unicode class for numbers + config.stderr_filter(r"\/home\/[\pL\pN_@#\-\. ]+", "$HOME"); + // Paths in .stderr seem to always be normalized to use /. Handle both anyway. + config.stderr_filter( + r"[a-zA-Z]:(?:\\|\/)users(?:\\|\/)[\pL\pN_@#\-\. ]+", // NOTE: [\pL\pN_@#\-\. ] is a poor attempt at handling usernames + "$HOME", + ); + + // Manually insert @aux-build: comments into test files. This needs to + // be done to build and link dependencies. Dependencies will be pulled from a + // Cargo.toml file. + config.comment_defaults.base().custom.insert( + "dependencies", + Spanned::dummy(vec![Box::new(DependencyBuilder::default())]), + ); + + Ok(config) +} + +/// Runs ui tests for a single directory. +/// +/// `root_dir` is the directory your tests are contained in. Needs to be a path from crate root. +pub fn test(test_name: impl Into, test_root: impl Into) -> ui_test::Result<()> { + test_multiple(test_name, [test_root]) +} + +/// Run ui tests with the given config +pub fn test_with_config(test_name: impl Into, config: Config) -> ui_test::Result<()> { + test_with_multiple_configs(test_name, [Ok(config)]) +} + +/// Runs ui tests for a multiple directories. +/// +/// `root_dirs` paths need to come from crate root. +pub fn test_multiple( + test_name: impl Into, + test_roots: impl IntoIterator>, +) -> ui_test::Result<()> { + let args = Args::test()?; + + let configs = test_roots.into_iter().map(|root| basic_config(root, &args)); + + test_with_multiple_configs(test_name, configs) +} + +/// Run ui test with the given configs. +/// +/// Tests for configs are run in parallel. +pub fn test_with_multiple_configs( + test_name: impl Into, + configs: impl IntoIterator>, +) -> ui_test::Result<()> { + let configs = configs.into_iter().collect::>>()?; + + let emitter: Box = if env::var_os("CI").is_some() { + Box::new((Text::verbose(), Gha:: { name: test_name.into() })) + } else { + Box::new(Text::quiet()) + }; + + run_tests_generic( + configs, + default_file_filter, + default_per_file_config, + emitter, + ) +} diff --git a/tools/compile_fail_utils/tests/example.rs b/tools/compile_fail_utils/tests/example.rs new file mode 100644 index 0000000..e409969 --- /dev/null +++ b/tools/compile_fail_utils/tests/example.rs @@ -0,0 +1,10 @@ +fn main() -> compile_test_utils::ui_test::Result<()> { + // Run all tests in the tests/example_tests folder. + // If we had more tests we could either call this function + // on every single one or use test_multiple and past it an array + // of paths. + // + // Don't forget that when running tests the working directory + // is set to the crate root. + compile_test_utils::test("tests/example_tests") +} diff --git a/tools/compile_fail_utils/tests/example_tests/basic_test.rs b/tools/compile_fail_utils/tests/example_tests/basic_test.rs new file mode 100644 index 0000000..0f8ab07 --- /dev/null +++ b/tools/compile_fail_utils/tests/example_tests/basic_test.rs @@ -0,0 +1,23 @@ +// Compiler warnings also need to be annotated. +// We don't want to annotate all the unused variables, so let's instruct the compiler to ignore them. +#![allow(unused_variables)] + +fn bad_moves() { + let x = String::new(); + // Help diagnostics need to be annotated + let y = x; + //~^ HELP: consider cloning + + // We expect a failure on this line + println!("{x}"); //~ ERROR: borrow + + + let x = String::new(); + // We expect the help message to mention cloning. + //~v HELP: consider cloning + let y = x; + + // Check error message using a regex + println!("{x}"); + //~^ ERROR: /(move)|(borrow)/ +} diff --git a/tools/compile_fail_utils/tests/example_tests/basic_test.stderr b/tools/compile_fail_utils/tests/example_tests/basic_test.stderr new file mode 100644 index 0000000..5fbd423 --- /dev/null +++ b/tools/compile_fail_utils/tests/example_tests/basic_test.stderr @@ -0,0 +1,39 @@ +error[E0382]: borrow of moved value: `x` + --> tests/example_tests/basic_test.rs:13:15 + | +7 | let x = String::new(); + | - move occurs because `x` has type `String`, which does not implement the `Copy` trait +8 | // Help diagnostics need to be annotated +9 | let y = x; + | - value moved here +... +13 | println!("{x}"); + | ^^^ value borrowed here after move + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +9 | let y = x.clone(); + | ++++++++ + +error[E0382]: borrow of moved value: `x` + --> tests/example_tests/basic_test.rs:22:15 + | +16 | let x = String::new(); + | - move occurs because `x` has type `String`, which does not implement the `Copy` trait +... +19 | let y = x; + | - value moved here +... +22 | println!("{x}"); + | ^^^ value borrowed here after move + | + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value if the performance cost is acceptable + | +19 | let y = x.clone(); + | ++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/tools/compile_fail_utils/tests/example_tests/import.rs b/tools/compile_fail_utils/tests/example_tests/import.rs new file mode 100644 index 0000000..2d2364b --- /dev/null +++ b/tools/compile_fail_utils/tests/example_tests/import.rs @@ -0,0 +1,7 @@ +// You can import anything defined in the dependencies table of the crate. +use ui_test::Config; + +fn wrong_type() { + let _ = Config::this_function_does_not_exist(); + //~^ E0599 +} diff --git a/tools/compile_fail_utils/tests/example_tests/import.stderr b/tools/compile_fail_utils/tests/example_tests/import.stderr new file mode 100644 index 0000000..c0d36fb --- /dev/null +++ b/tools/compile_fail_utils/tests/example_tests/import.stderr @@ -0,0 +1,20 @@ +error[E0599]: no function or associated item named `this_function_does_not_exist` found for struct `Config` in the current scope + --> tests/example_tests/import.rs:5:21 + | +5 | let _ = Config::this_function_does_not_exist(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `Config` + | +note: if you're trying to build a new `Config` consider using one of the following associated functions: + Config::rustc + Config::cargo + --> $RUSTUP_HOME/.cargo/git/checkouts/ui_test-2b82183a391bb05c/680bb08/src/config.rs:63:5 + | +63 | pub fn rustc(root_dir: impl Into) -> Self { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +108 | pub fn cargo(root_dir: impl Into) -> Self { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tools/compile_fail_utils/tests/example_tests/pass_test.rs b/tools/compile_fail_utils/tests/example_tests/pass_test.rs new file mode 100644 index 0000000..6216492 --- /dev/null +++ b/tools/compile_fail_utils/tests/example_tests/pass_test.rs @@ -0,0 +1,10 @@ +//@check-pass + +// This code is expected to compile correctly. +fn correct_borrowing() { + let x = String::new(); + let y = &x; + + println!("{x}"); + println!("{y}"); +} diff --git a/tools/compile_fail_utils/tests/example_tests/pass_test.stderr b/tools/compile_fail_utils/tests/example_tests/pass_test.stderr new file mode 100644 index 0000000..975c7d2 --- /dev/null +++ b/tools/compile_fail_utils/tests/example_tests/pass_test.stderr @@ -0,0 +1,10 @@ +warning: function `correct_borrowing` is never used + --> tests/example_tests/pass_test.rs:4:4 + | +4 | fn correct_borrowing() { + | ^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(dead_code)]` on by default + +warning: 1 warning emitted + diff --git a/tools/publish.sh b/tools/publish.sh new file mode 100644 index 0000000..c30ca2f --- /dev/null +++ b/tools/publish.sh @@ -0,0 +1,29 @@ +# if crate A depends on crate B, B must come before A in this list +crates=( +) + +if [ -n "$(git status --porcelain)" ]; then + echo "You have local changes!" + exit 1 +fi + +pushd crates + +for crate in "${crates[@]}"; do + echo "Publishing ${crate}" + cp ../LICENSE-MIT "$crate" + cp ../LICENSE-APACHE "$crate" + pushd "$crate" + git add LICENSE-MIT LICENSE-APACHE + cargo publish --no-verify --allow-dirty + popd + sleep 20 +done + +popd + +echo "Publishing root crate" +cargo publish --allow-dirty + +echo "Cleaning local state" +git reset HEAD --hard diff --git a/typos.toml b/typos.toml new file mode 100644 index 0000000..295a362 --- /dev/null +++ b/typos.toml @@ -0,0 +1,23 @@ +[files] +extend-exclude = [ + "*.patch", # Automatically generated files that should not be manually modified. + "*.bin", # Binary files + ".git/", # Version control files +] +ignore-hidden = false + +# Corrections take the form of a key/value pair. The key is the incorrect word +# and the value is the correct word. If the key and value are the same, the +# word is treated as always correct. If the value is an empty string, the word +# is treated as always incorrect. + +# Match Whole Word - Case Sensitive +[default.extend-identifiers] + +# Match Inside a Word - Case Insensitive +[default.extend-words] + +[default] +locale = "en-us" +extend-ignore-identifiers-re = [ +]