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

chore: initial bootstrapped template #1

Merged
merged 1 commit into from
Apr 18, 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
4 changes: 4 additions & 0 deletions .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
_commit: v2.0.5
_src_path: gh:dafyddj/copier-bootstrap
template_name: copier-packer-build
31 changes: 31 additions & 0 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"enabledManagers": [
"custom.regex",
"git-submodules",
],
"extends": [
"config:recommended",
],
// `copier` template updates
// There are two conditions that we need to account for
// * a "clean" `.copier-answers.yml` file
// * update needed but not yet applied (and further updates could appear in this condition)
// `renovate` needs to be able to match both conditions for PRs to work properly
// We make a hacky use of the otherwise unused field `currentDigest` to hold the current copier template version
"customManagers": [
{
"customType": "regex",
"fileMatch": ["^.copier-answers.yml$"],
"matchStrings": [
"_commit: (?<currentValue>\\S+)\\n_src_path: gh:(?<depName>\\S+)\\n",
"_commit: (?<currentDigest>\\S+) # __copier_update_needed (?<currentValue>\\S+)\\n_src_path: gh:(?<depName>\\S+)\\n",
],
"datasourceTemplate": "github-tags",
"autoReplaceStringTemplate": "_commit: {{#if currentDigest}}{{{currentDigest}}}{{else}}{{{currentValue}}}{{/if}} # __copier_update_needed {{{newValue}}}\n_src_path: gh:{{{depName}}}\n",
},
],
"git-submodules": {
"enabled": true
},
}
62 changes: 62 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
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
env:
# renovate: datasource=github-releases depName=actions/python-versions extractVersion=^(?<version>\S+)-\d+$
PYTHON_VERSION: 3.12.3
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-python@82c7e631bb3cdc910f68e0081d67478d79c6982d # v5.1.0
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
test:
name: Run approval tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
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@b3db6e16e597d92037c8647e54acc5d2b1b48dee # v3.18
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: codfish/semantic-release-action@b0e57c976bf8f74b2454f59a30e4a1b5f11727b4 # v3.3.0
with:
plugins: |
[ "@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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.6.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.28.2
hooks:
- id: check-github-workflows
name: Check GitHub workflows with check-jsonschema
args: ["--verbose"]
- id: check-renovate
name: Check Renovate config with check-jsonschema
additional_dependencies: [json5==0.9.14]
args: ["--verbose"]
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 "$@"
2 changes: 2 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_subdirectory: template
_templates_suffix: .copier-jinja
31 changes: 31 additions & 0 deletions template/.github/renovate.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"enabledManagers": [
"custom.regex",
"git-submodules",
],
"extends": [
"config:recommended",
],
// `copier` template updates
// There are two conditions that we need to account for
// * a "clean" `.copier-answers.yml` file
// * update needed but not yet applied (and further updates could appear in this condition)
// `renovate` needs to be able to match both conditions for PRs to work properly
// We make a hacky use of the otherwise unused field `currentDigest` to hold the current copier template version
"customManagers": [
{
"customType": "regex",
"fileMatch": ["^.copier-answers.yml$"],
"matchStrings": [
"_commit: (?<currentValue>\\S+)\\n_src_path: gh:(?<depName>\\S+)\\n",
"_commit: (?<currentDigest>\\S+) # __copier_update_needed (?<currentValue>\\S+)\\n_src_path: gh:(?<depName>\\S+)\\n",
],
"datasourceTemplate": "github-tags",
"autoReplaceStringTemplate": "_commit: {{#if currentDigest}}{{{currentDigest}}}{{else}}{{{currentValue}}}{{/if}} # __copier_update_needed {{{newValue}}}\n_src_path: gh:{{{depName}}}\n",
},
],
"git-submodules": {
"enabled": true
},
}
2 changes: 2 additions & 0 deletions template/{{ _copier_conf.answers_file }}.copier-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 -}}
5 changes: 5 additions & 0 deletions test/GenerateProject/catalogue.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The following new files/directories were created:
<Test Directory>
----.copier-answers.yml
----.github
--------renovate.json5
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/.. .
8 changes: 8 additions & 0 deletions test/GenerateProject/stderr.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/opt/homebrew/Cellar/copier/9.2.0/libexec/lib/python3.12/site-packages/copier/vcs.py:202: DirtyLocalWarning: Dirty template changes included automatically.
warn(

Copying from template version 0.0.0.post2.dev0+2261517
 identical .
 create .copier-answers.yml
 create .github
 create .github/renovate.json5
2 changes: 2 additions & 0 deletions test/GenerateProject/stdout.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@


20 changes: 20 additions & 0 deletions test/config.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# 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-packer-build

create_catalogues:true

[run_dependent_text]
stderr:Copying from template version
stderr:DirtyLocalWarning{LINES 2}
stderr:No git tags found in template; using HEAD as ref
stderr:create
stderr:conflict
stderr:identical
stderr:overwrite
stderr:skip
1 change: 1 addition & 0 deletions test/options.tt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
copy --defaults --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