-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea00a71
commit e765a7b
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: CI | ||
|
||
on: push | ||
# pull_request: | ||
# branches: | ||
# - main | ||
|
||
jobs: | ||
drift-check: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Rust toolchain | ||
uses: dtolnay/rust-toolchain@stable | ||
|
||
- name: Install Bevy CLI | ||
run: | | ||
cargo install --git https://github.com/thebevyflock/bevy_cli | ||
- name: Retain a copy of every generated file | ||
run: | | ||
for template_file in $(find . -type f -name "*.template"); do | ||
generated_file="${template_file%.template}" | ||
if [ -f "$generated_file" ]; then | ||
# Keep a copy to diff with the output of the next step | ||
cp "$generated_file" "${generated_file}.check" | ||
fi | ||
done | ||
- name: Generate from templates | ||
run: | | ||
# Note: this would be slightly improved by having the ability to generate from local | ||
# templates, as cargo-generate can. | ||
bevy new foo -t "$REPO" -b "$BRANCH" | ||
env: | ||
REPO: ${{ github.repository }} | ||
BRANCH: ${{ github.ref_name }} | ||
|
||
- name: Check for drift between templates and generated files | ||
run: | | ||
for check_file in $(find . -type f -name "*.check"); do | ||
generated_file="${check_file%.check}" | ||
if ! diff "$check_file" "$generated_file" > /dev/null; then | ||
echo "File $generated_file has drift from $generated_file.template:" | ||
diff "$check_file" "$generated_file" || true | ||
echo "::error file=$generated_file::Template drift detected." | ||
fi | ||
done | ||
- name: Remove check files | ||
run: | | ||
find . -type f -name "*.check" -delete |