Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for drift between .template files and generated files #13

Merged
merged 35 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
e765a7b
Check for template drift
bas-ie Sep 18, 2024
de4993c
Specifically install bevy_cli
bas-ie Sep 18, 2024
181651e
Use cargo-generate
bas-ie Sep 18, 2024
6365d15
Fail the step on diff
bas-ie Sep 18, 2024
f8407e6
Correct name, introduce a change
bas-ie Sep 18, 2024
d567f3a
Correct generate command
bas-ie Sep 18, 2024
86c3e20
Add cache, correct repo name
bas-ie Sep 18, 2024
9b5f608
Remove diff, shift env
bas-ie Sep 18, 2024
039df59
Do we really need to diff twice?
bas-ie Sep 18, 2024
18cf990
Always exit with error if diff
bas-ie Sep 18, 2024
221f99d
Avoid removing directory for now
bas-ie Sep 18, 2024
c8813a5
Stop using cargo-sweep
bas-ie Sep 18, 2024
93b71df
Explicitly turn off sweep
bas-ie Sep 18, 2024
4d14764
Trial install-action
bas-ie Sep 18, 2024
e4e0ca5
Restore PR run criteria, remove cleanup step
bas-ie Sep 18, 2024
0088aa6
Update .github/workflows/ci-generate.yaml
bas-ie Sep 19, 2024
45a20bd
Update .github/workflows/ci-generate.yaml
bas-ie Sep 19, 2024
1088641
Update .github/workflows/ci-generate.yaml
bas-ie Sep 19, 2024
bd3023d
Update .github/workflows/ci-generate.yaml
bas-ie Sep 19, 2024
1e62e80
Ignore ci-generate.yaml
bas-ie Sep 19, 2024
3d89aa3
Apply PR feedback
bas-ie Sep 19, 2024
1ea4126
Typo
bas-ie Sep 19, 2024
8f99168
Check behaviour with two changes
bas-ie Sep 19, 2024
7a11229
Heh
bas-ie Sep 19, 2024
9fac185
Revert env echo
bas-ie Sep 19, 2024
1bacef5
Meh
bas-ie Sep 19, 2024
8299e4a
Revert env echo
bas-ie Sep 19, 2024
69c2788
Check
bas-ie Sep 19, 2024
fa90c50
Return to the double-diff
bas-ie Sep 19, 2024
2e689ae
Check
bas-ie Sep 19, 2024
63885ab
ah
bas-ie Sep 19, 2024
88aad90
Just curious
bas-ie Sep 19, 2024
7f91f13
Check single quotes again
bas-ie Sep 19, 2024
afb5a03
Revert check
bas-ie Sep 19, 2024
049ce90
Merge branch 'main' into 5-ci-generate
bas-ie Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/ci-generate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
pull_request:
branches:
- main
bas-ie marked this conversation as resolved.
Show resolved Hide resolved

jobs:
check-drift:
runs-on: ubuntu-latest
env:
REPO: ${{ github.event.repository.name }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

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

- name: Install cargo-generate
uses: taiki-e/install-action@v2
with:
tool: cargo-generate
benfrankel marked this conversation as resolved.
Show resolved Hide resolved

- name: Retain a copy of every generated file
bas-ie marked this conversation as resolved.
Show resolved Hide resolved
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
bas-ie marked this conversation as resolved.
Show resolved Hide resolved
run: |
# Note: we use cargo-generate itself here as our wrapping of the cargo-generate library
# does not allow us to do useful things like --allow-commands and use local templates.
bas-ie marked this conversation as resolved.
Show resolved Hide resolved
cargo generate --path . --name '${{ env.REPO }}' --allow-commands

- name: Check for drift between templates and generated files
bas-ie marked this conversation as resolved.
Show resolved Hide resolved
run: |
for check_file in $(find '${{ env.REPO }}' -type f -name '*.check'); do
generated_file="${check_file%.check}"
if ! diff "${check_file}" "${generated_file}"; then
echo "File ${generated_file} has drift from ${generated_file}.template:"
echo "::error file=${generated_file}::Template drift detected."
exit 1
bas-ie marked this conversation as resolved.
Show resolved Hide resolved
fi
done
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "bevy_new"
name = "bevy_new_minimal"
version = "0.1.0"
edition = "2021"

Expand Down