Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
kainosaur authored Aug 18, 2024
0 parents commit 546575c
Show file tree
Hide file tree
Showing 60 changed files with 8,212 additions and 0 deletions.
147 changes: 147 additions & 0 deletions .cargo/config_fast_builds.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Copy this file to `config.toml` to speed up your builds.
#
# # Faster linker
#
# One of the slowest aspects of compiling large Rust programs is the linking time. This file configures an
# alternate linker that may improve build times. When choosing a new linker, you have two options:
#
# ## LLD
#
# LLD is a linker from the LLVM project that supports Linux, Windows, MacOS, and WASM. It has the greatest
# platform support and the easiest installation process. It is enabled by default in this file for Linux
# and Windows. On MacOS, the default linker yields higher performance than LLD and is used instead.
#
# To install, please scroll to the corresponding table for your target (eg. `[target.x86_64-pc-windows-msvc]`
# for Windows) and follow the steps under `LLD linker`.
#
# For more information, please see LLD's website at <https://lld.llvm.org>.
#
# ## Mold
#
# Mold is a newer linker written by one of the authors of LLD. It boasts even greater performance, specifically
# through its high parallelism, though it only supports Linux.
#
# Mold is disabled by default in this file. If you wish to enable it, follow the installation instructions for
# your corresponding target, disable LLD by commenting out its `-Clink-arg=...` line, and enable Mold by
# *uncommenting* its `-Clink-arg=...` line.
#
# There is a fork of Mold named Sold that supports MacOS, but it is unmaintained and is about the same speed as
# the default ld64 linker. For this reason, it is not included in this file.
#
# For more information, please see Mold's repository at <https://github.com/rui314/mold>.
#
# # Nightly configuration
#
# Be warned that the following features require nightly Rust, which is expiremental and may contain bugs. If you
# are having issues, skip this section and use stable Rust instead.
#
# There are a few unstable features that can improve performance. To use them, first install nightly Rust
# through Rustup:
#
# ```
# rustup toolchain install nightly
# ```
#
# Finally, uncomment the lines under the `Nightly` heading for your corresponding target table (eg.
# `[target.x86_64-unknown-linux-gnu]` for Linux) to enable the following features:
#
# ## `share-generics`
#
# Usually rustc builds each crate separately, then combines them all together at the end. `share-generics` forces
# crates to share monomorphized generic code, so they do not duplicate work.
#
# In other words, instead of crate 1 generating `Foo<String>` and crate 2 generating `Foo<String>` separately,
# only one crate generates `Foo<String>` and the other adds on to the pre-exiting work.
#
# Note that you may have some issues with this flag on Windows. If compiling fails due to the 65k symbol limit,
# you may have to disable this setting. For more information and possible solutions to this error, see
# <https://github.com/bevyengine/bevy/issues/1110>.
#
# ## `threads`
#
# This option enables rustc's parallel frontend, which improves performance when parsing, type checking, borrow
# checking, and more. We currently set `threads=0`, which defaults to the amount of cores in your CPU.
#
# For more information, see the blog post at <https://blog.rust-lang.org/2023/11/09/parallel-rustc.html>.

[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = [
# LLD linker
#
# You may need to install it:
#
# - Ubuntu: `sudo apt-get install lld clang`
# - Fedora: `sudo dnf install lld clang`
# - Arch: `sudo pacman -S lld clang`
"-Clink-arg=-fuse-ld=lld",

# Mold linker
#
# You may need to install it:
#
# - Ubuntu: `sudo apt-get install mold clang`
# - Fedora: `sudo dnf install mold clang`
# - Arch: `sudo pacman -S mold clang`
# "-Clink-arg=-fuse-ld=/usr/bin/mold",

# Nightly
# "-Zshare-generics=y",
# "-Zthreads=0",
]

[target.x86_64-apple-darwin]
rustflags = [
# LLD linker
#
# The default ld64 linker is faster, you should continue using it instead.
#
# You may need to install it:
#
# Brew: `brew install llvm`
# Manually: <https://lld.llvm.org/MachO/index.html>
# "-Clink-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld",

# Nightly
# "-Zshare-generics=y",
# "-Zthreads=0",
]

[target.aarch64-apple-darwin]
rustflags = [
# LLD linker
#
# The default ld64 linker is faster, you should continue using it instead.
#
# You may need to install it:
#
# Brew: `brew install llvm`
# Manually: <https://lld.llvm.org/MachO/index.html>
# "-Clink-arg=-fuse-ld=/opt/homebrew/opt/llvm/bin/ld64.lld",

# Nightly
# "-Zshare-generics=y",
# "-Zthreads=0",
]

[target.x86_64-pc-windows-msvc]
# LLD linker
#
# You may need to install it:
#
# ```
# cargo install -f cargo-binutils
# rustup component add llvm-tools
# ```
linker = "rust-lld.exe"
rustdocflags = ["-Clinker=rust-lld.exe"]
rustflags = [
# Nightly
# "-Zshare-generics=n", # This needs to be off if you use dynamic linking on Windows.
# "-Zthreads=0",
]

# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'
# In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains.
# [profile.dev]
# debug = 1
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[.github/workflows/*.{yaml,yml}]
indent_size = 2
124 changes: 124 additions & 0 deletions .github/workflows/cargo-generate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# This workflow is used to automatically update the `cargo-generate` branch. If you copied the
# template, you can safely delete this. :)
#
# BE VERY CAREFUL about what this workflow runs, since IT HAS THE ABILITY TO DELETE THE ENTIRE
# REPOSITORY'S CONTENTS. For this reason, stick to pre-installed tools and trusted actions (such as
# those hosted from the `actions` organization.)

name: Update `cargo-generate` branch

on:
# Update `cargo-generate` from `main` every time `main` is updated.
push:
branches: main
# Allow this workflow to be manually triggered.
workflow_dispatch:

# This workflows also has write-access for content and workflow, but it is through
# CARGO_GENERATE_PAT.
permissions:
# We need write permissions to create new issues.
issues: write

jobs:
update:
runs-on: ubuntu-latest
# Only run this job on the source repository, skipping forks.
if: ${{ github.repository == 'TheBevyFlock/bevy_quickstart' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Fetch entire history, since we need it all to successfully merge.
fetch-depth: 0
# Specify a personal access token, since the default one does not let workflows modify
# the `.github/workflows` folder. This PAT needs write permissions for Contents and
# Workflows. I recommend creating a scoped token that only has access to this repository.
token: ${{ secrets.CARGO_GENERATE_PAT }}

- name: Configure Git user
env:
# From https://github.com/actions/checkout/pull/1707.
NAME: github-actions[bot]
EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
run: |
git config user.name "${NAME}"
git config user.email "${EMAIL}"
- name: Switch to `cargo-generate` branch
run: git checkout cargo-generate

- name: Merge `main` branch into `cargo-generate`
id: merge
# We use `--no-edit` to prevent any editor from being opened, since we can't close it.
run: git merge main --no-edit --verbose

- name: Handle merge conflict
# Only run this if merging failed.
if: ${{ failure() && steps.merge.outcome == 'failure' }}
env:
TITLE: Failed to auto-update `cargo-generate`
BODY: |
There were merge conflicts while trying to update `cargo-generate` from `main`. You can
do it manually by running:
```bash
# Update your local copy of the `main` branch.
git switch main
git pull
# Checkout the `cargo-generate` branch.
git checkout cargo-generate
# Merge changes from `main` to `cargo-generate`. You will have to fix merge conflicts.
git merge main
```
<details>
<summary><code>git status</code></summary>
```
GIT_STATUS_IDENTIFIER
```
</details>
<details>
<summary><code>git diff --diff-filter=U</code></summary>
```diff
GIT_DIFF_IDENTIFIER
```
</details>
_This is an automated message created by `cargo-generate.yaml`._
# This is required to use the `gh` CLI.
GH_TOKEN: ${{ github.token }}
run: |
# Get a list of the IDs of open issues created by this action, then count them using JQ.
OPEN_ISSUES="$(
gh issue list \
--search "is:issue is:open author:app/github-actions in:title ${TITLE}" \
--json id \
--jq '. | length'
)"
# If an issue already exists, do not create another.
if [[ "${OPEN_ISSUES}" -gt 0 ]]; then
echo 'An issue already exists on merge conflicts! Exiting without creating another.'
exit 0
fi
GIT_STATUS="$(git status)"
# Filter the diff to only include files with merge conflicts.
GIT_DIFF="$(git diff --diff-filter=U)"
# Replace `GIT_STATUS_IDENTIFIER` and `GIT_DIFF_IDENTIFIER` with their outputs.
BODY="${BODY/GIT_STATUS_IDENTIFIER/"${GIT_STATUS}"}"
BODY="${BODY/GIT_DIFF_IDENTIFIER/"${GIT_DIFF}"}"
# Create the issue.
gh issue create --title "${TITLE}" --body "${BODY}"
- name: Push changes
# Only run if merging succeeded.
if: ${{ success() && steps.merge.outcome == 'success' }}
run: git push
98 changes: 98 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings
RUSTDOCFLAGS: --deny warnings

jobs:
# Run tests.
test:
name: Tests
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2

- name: Run tests
run: |
cargo test --workspace --all-features --all-targets
# Workaround for https://github.com/rust-lang/cargo/issues/6669
cargo test --workspace --all-features --doc
# Run clippy lints.
clippy:
name: Clippy
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2

- name: Run clippy lints
run: cargo clippy --workspace --all-targets --all-features -- --deny warnings

# Check formatting.
format:
name: Format
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Run cargo fmt
run: cargo fmt --all -- --check

# Check documentation.
doc:
name: Docs
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev

- name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2

- name: Check documentation
run: cargo doc --workspace --all-features --document-private-items --no-deps
Loading

0 comments on commit 546575c

Please sign in to comment.