Skip to content

Commit

Permalink
Merge pull request #1 from dafyddj/feat/initial
Browse files Browse the repository at this point in the history
feat: initial version of `copier-bootstrap`
  • Loading branch information
dafyddj authored Jan 10, 2024
2 parents d78d0d9 + 5f134cc commit 04b9116
Show file tree
Hide file tree
Showing 27 changed files with 243 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Test & release

on:
pull_request:
push:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}

jobs:
pre-commit:
name: Run `pre-commit`
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
test:
name: Run approval tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # `copier` prefers full-history clones
submodules: true
- name: Debug on runner (When re-run with "Enable debug logging" checked)
if: runner.debug
uses: mxschmitt/action-tmate@v3
with:
detached: true
- name: Install test dependencies
run: |
pipx install copier
pipx install texttest
- name: Run `texttest`
run: texttest -b
results:
name: Collect results
needs:
- pre-commit
- test
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: codfish/semantic-release-action@v3
with:
plugins: |
[ "@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "base"]
path = base
url = https://github.com/dafyddj/base-bootstrap
19 changes: 19 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
args: [--assume-in-merge]
- id: check-yaml
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: check-github-workflows
name: Check GitHub workflows with check-jsonschema
args: ["--verbose"]
- id: check-renovate
name: Check Renovate config with check-jsonschema
args: ["--verbose"]
1 change: 1 addition & 0 deletions base
Submodule base added at f42eb5
10 changes: 10 additions & 0 deletions bin/copier
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Check if the copier binary exists
if ! [ -x "$(command -v copier)" ]; then
echo "Error: 'copier' binary not found or not executable"
exit 1
fi

# Call the copier binary with all command line arguments
copier "$@"
1 change: 1 addition & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_subdirectory: template
57 changes: 57 additions & 0 deletions template/.github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Test & release

on:
pull_request:
push:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}

jobs:
pre-commit:
name: Run `pre-commit`
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- uses: pre-commit/[email protected]
test:
name: Run approval tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # `copier` prefers full-history clones
submodules: true
- name: Debug on runner (When re-run with "Enable debug logging" checked)
if: runner.debug
uses: mxschmitt/action-tmate@v3
with:
detached: true
- name: Install test dependencies
run: |
pipx install copier
pipx install texttest
- name: Run `texttest`
run: texttest -b
results:
name: Collect results
needs:
- pre-commit
- test
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: codfish/semantic-release-action@v3
with:
plugins: |
[ "@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 19 additions & 0 deletions template/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-merge-conflict
args: [--assume-in-merge]
- id: check-yaml
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.3
hooks:
- id: check-github-workflows
name: Check GitHub workflows with check-jsonschema
args: ["--verbose"]
- id: check-renovate
name: Check Renovate config with check-jsonschema
args: ["--verbose"]
10 changes: 10 additions & 0 deletions template/bin/copier
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Check if the copier binary exists
if ! [ -x "$(command -v copier)" ]; then
echo "Error: 'copier' binary not found or not executable"
exit 1
fi

# Call the copier binary with all command line arguments
copier "$@"
1 change: 1 addition & 0 deletions template/copier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_subdirectory: template
Empty file added template/template/.gitkeep
Empty file.
3 changes: 3 additions & 0 deletions template/test/GenerateProject/catalogue.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The following new files/directories were created:
<Test Directory>
----.gitkeep
1 change: 1 addition & 0 deletions template/test/GenerateProject/options.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$TEXTTEST_ROOT/.. .
2 changes: 2 additions & 0 deletions template/test/GenerateProject/stdout.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


11 changes: 11 additions & 0 deletions template/test/config.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Full path to the System Under Test (or Java Main Class name)
executable:${TEXTTEST_ROOT}/../bin/copier

# Naming scheme to use for files for stdin,stdout and stderr
filename_convention_scheme:standard

# Expanded name to use for application
full_name:Copier Test

create_catalogues:true
discard_file:stderr
1 change: 1 addition & 0 deletions template/test/options.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
copy --vcs-ref=HEAD
1 change: 1 addition & 0 deletions template/test/testsuite.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GenerateProject
2 changes: 2 additions & 0 deletions template/{{ _copier_conf.answers_file }}.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
{{ _copier_answers|to_nice_yaml -}}
20 changes: 20 additions & 0 deletions test/GenerateProject/catalogue.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The following new files/directories were created:
<Test Directory>
----.copier-answers.yml
----.github
--------workflows
------------main.yml
----.pre-commit-config.yaml
----bin
--------copier
----copier.yaml
----template
--------.gitkeep
----test
--------config.tt
--------options.tt
--------testsuite.tt
--------GenerateProject
------------catalogue.tt
------------options.tt
------------stdout.tt
1 change: 1 addition & 0 deletions test/GenerateProject/config_tt.tt
1 change: 1 addition & 0 deletions test/GenerateProject/main_yml.tt
1 change: 1 addition & 0 deletions test/GenerateProject/options.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$TEXTTEST_ROOT/.. .
1 change: 1 addition & 0 deletions test/GenerateProject/pre-commit_yaml.tt
2 changes: 2 additions & 0 deletions test/GenerateProject/stdout.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


16 changes: 16 additions & 0 deletions test/config.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Full path to the System Under Test (or Java Main Class name)
executable:${TEXTTEST_ROOT}/../bin/copier

# Naming scheme to use for files for stdin,stdout and stderr
filename_convention_scheme:standard

# Expanded name to use for application
full_name:Copier Test

create_catalogues:true
discard_file:stderr

[collate_file]
config_tt:test/config.tt
main_yml:.github/workflows/main.yml
pre-commit_yaml:.pre-commit-config.yaml
1 change: 1 addition & 0 deletions test/options.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
copy --vcs-ref=HEAD
1 change: 1 addition & 0 deletions test/testsuite.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GenerateProject

0 comments on commit 04b9116

Please sign in to comment.