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

add jinja validate workflow #9

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions .github/workflows/jinja.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
workflow_call:
inputs:
workdir:
required: false
default: "./"
type: string

jobs:
validate:
runs-on: ubuntu-latest
if: "!startsWith(github.ref, 'refs/tags/')"
container:
image: cubicrootxyz/jinja:v0.0.3
options: --user root
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Run tests
run: (cd ${{ inputs.workdir }} && makejinja)
- name: Check for diffs
run: git diff --exit-code
7 changes: 7 additions & 0 deletions .github/workflows/jinja_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
on: push

jobs:
jinja:
uses: ./.github/workflows/jinja.yaml
with:
workdir: "tests/jinja/"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,18 @@ jobs:
workdir: "tests/golang_test/"
services: '{"database": {"image": "mysql:8.0", "ports": ["3306:3306"]}}'
env: '{"TESTENV": "value"}'
```

## Jinja

### Validate generates are up to date

Add the following job to your CI to ensure `jinja` generated files are always up to date. Uses `makejinja` for templating.

```yaml
jobs:
jinja:
uses: CubicrootXYZ/Workflows/.github/workflows/[email protected]
with:
workdir: "tests/jinja/"
```
3 changes: 3 additions & 0 deletions tests/jinja/generated/testfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- a
- b
- c
3 changes: 3 additions & 0 deletions tests/jinja/makejinja.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[makejinja]
inputs = ["./templates"]
output = "./generated"
3 changes: 3 additions & 0 deletions tests/jinja/templates/testfile.yml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% for item in ["a", "b", "c"] %}
- {{ item }}
{% endfor %}
Loading