-
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
Showing
9 changed files
with
184 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,115 @@ | ||
name: 'Continuous Testing' | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
test-script: | ||
name: Script Tests | ||
runs-on: ubuntu-latest | ||
permissions: | ||
checks: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install bats | ||
id: install-bats | ||
run: ./test/install_bats.sh | ||
|
||
- name: Install Jinja2-cli | ||
id: install-jinja2 | ||
run: pip install jinja2-cli | ||
|
||
- name: Test | ||
id: script-test | ||
run: ./test/bats/bin/bats --report-formatter junit test/test_process_file.bats | ||
|
||
- name: Testspace client install & config | ||
id: testspace_init | ||
if: always() && hashFiles('report.xml') != '' | ||
uses: testspace-com/setup-testspace@v1 | ||
with: | ||
domain: ${{github.repository_owner}} | ||
|
||
- name: Testspace push test content | ||
if: always() && (steps.testspace_init.outcome == 'success') | ||
run: | | ||
testspace "[Unit Tests]report.xml" | ||
- name: Publish Test Results in GitHub | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: report.xml | ||
check_name: 'Unit Test Results' | ||
|
||
- name: TEMP | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: unit | ||
path: report.xml | ||
|
||
test-action: | ||
name: GitHub Actions Test | ||
runs-on: ubuntu-latest | ||
permissions: | ||
checks: write | ||
pull-requests: write | ||
if: (github.event_name == 'pull_request') && (github.base_ref == 'main') | ||
steps: | ||
- name: Checkout | ||
id: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install bats | ||
id: install-bats | ||
run: ./test/install_bats.sh | ||
|
||
- name: Test Local Action | ||
id: test-action | ||
uses: ./ | ||
env: | ||
TEST: integ | ||
|
||
- name: Check If Template file is managed | ||
id: test-action-result | ||
run: ./test/bats/bin/bats --report-formatter junit test/test_action.bats | ||
|
||
- name: Testspace client install & config | ||
id: testspace_init | ||
if: always() && hashFiles('report.xml') != '' | ||
uses: testspace-com/setup-testspace@v1 | ||
with: | ||
domain: ${{github.repository_owner}} | ||
|
||
- name: Testspace push test content | ||
if: always() && (steps.test-action-result.outcome == 'success') | ||
run: | | ||
testspace "[Integ Tests]report.xml" | ||
- name: Publish Test Results in GitHub | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: report.xml | ||
check_name: 'Integ Test Results' | ||
|
||
- name: TEMP | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: integ | ||
path: report.xml | ||
|
||
|
||
|
||
|
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,2 @@ | ||
# bats junit test result file | ||
report.xml |
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,19 @@ | ||
name: 'Jinja2 Engine Repo' | ||
description: 'Use the Jinja2 templating engine on multiple files' | ||
author: 'fletort' | ||
branding: | ||
icon: 'sliders' | ||
color: 'red' | ||
# inputs: | ||
# templates_mask: | ||
# description: | ||
# 'Mask Used to detect templates files' | ||
# default: '*.j2' | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: "Manage Dynamic Template" | ||
shell: bash | ||
run: | | ||
pip install jinja2-cli | ||
find . -name '*.j2' -exec ./process_file.sh {} \; |
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,6 @@ | ||
#!/bin/bash | ||
template_file=$1 | ||
# remove j2 extension | ||
final_file="${template_file%.*}" | ||
jinja2 $template_file > $final_file | ||
rm $template_file |
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,2 @@ | ||
bats | ||
test_helper |
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,4 @@ | ||
#!/bin/bash | ||
git -c advice.detachedHead=false clone --depth 1 --branch v1.11.0 https://github.com/bats-core/bats-core.git test/bats | ||
git -c advice.detachedHead=false clone --depth 1 --branch v2.1.0 https://github.com/bats-core/bats-assert.git test/test_helper/bats-assert | ||
git -c advice.detachedHead=false clone --depth 1 --branch v0.4.0 https://github.com/bats-core/bats-file.git test/test_helper/bats-file |
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 @@ | ||
{{ environ('TEST') }} |
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,13 @@ | ||
#!/usr/bin/env bats | ||
|
||
setup() { | ||
load 'test_helper/bats-assert/load' | ||
load 'test_helper/bats-file/load' | ||
} | ||
|
||
@test "action result" { | ||
assert_file_not_exist test/template.j2 | ||
assert_file_exist test/template | ||
content=$(cat test/template) | ||
assert_equal $content 'integ' | ||
} |
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,22 @@ | ||
#!/usr/bin/env bats | ||
|
||
setup() { | ||
load 'test_helper/bats-assert/load' | ||
load 'test_helper/bats-file/load' | ||
} | ||
|
||
@test "rename template file" { | ||
cp test/template.j2 test.txt.j2 | ||
./process_file.sh test.txt.j2 | ||
assert_file_exist test.txt | ||
rm test.txt | ||
} | ||
|
||
@test "process template file" { | ||
cp test/template.j2 test.txt.j2 | ||
export TEST=toto | ||
./process_file.sh test.txt.j2 | ||
content=$(cat test.txt) | ||
assert_equal $content 'toto' | ||
rm test.txt | ||
} |