Skip to content

Commit f4e649e

Browse files
committed
refactor: Incorporate 2.1.10 version of The Common Project Template
Signed-off-by: 林博仁(Buo-ren, Lin) <[email protected]>
1 parent bd7b771 commit f4e649e

23 files changed

+1526
-305
lines changed

.editorconfig

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# http://EditorConfig.org
33
#
44
# This file is based on The Common EditorConfig Template project
5-
# https://github.com/Lin-Buo-Ren/the-common-editorconfig-template
5+
# https://github.com/the-common/editorconfig-template
66
#
77
# Copyright 2021 林博仁(Buo-ren, Lin) <[email protected]>
88
# SPDX-License-Identifier: WTFPL
@@ -19,6 +19,10 @@ charset = utf-8
1919
insert_final_newline = true
2020
trim_trailing_whitespace = true
2121

22+
# Git configuration files uses tabs as indentation units
23+
[/.git{modules,config}]
24+
indent_style = tab
25+
2226
# Avoid git patch fail to apply due to stripped unmodified lines that contains only spaces
2327
[/.git/**]
2428
trim_trailing_whitespace = false
@@ -37,6 +41,10 @@ trim_trailing_whitespace = false
3741
# Markdownlint to check instead
3842
indent_size = unset
3943

44+
[*.{diff,patch}]
45+
# Trailing whitespaces are unchanged lines in patch files
46+
trim_trailing_whitespace = false
47+
4048
# Vagrant configuration file
4149
[Vagrantfile]
4250
indent_size = 2
@@ -48,3 +56,11 @@ indent_size = 2
4856
# YAML documents
4957
[*.{yml,yaml}]
5058
indent_size = 2
59+
60+
[.*.{yml,yaml}]
61+
indent_size = 2
62+
63+
# Keep the indentation style of the license text verbatim
64+
[/LICENSES/*]
65+
indent_size = unset
66+
indent_style = unset

.gitattributes

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
11
# Git path attributes configuration file
22
#
3-
# Defining attributes per path
3+
# References:
44
#
5-
# Reference:
6-
# - Git - gitattributes Documentation
7-
# https://git-scm.com/docs/gitattributes
5+
# * Git - Git Attributes
6+
# https://git-scm.com/book/en/v2/Customizing-Git-Git-Attributes
7+
# * Git - gitattributes Documentation
8+
# https://www.git-scm.com/docs/gitattributes
89
#
9-
# This file is based on The Commons Gitattributes Templates
10-
# https://gitlab.com/brlin/the-commons-gitattributes-templates
11-
# SPDX-License-Identifier: CC-BY-SA-4.0
12-
# Copyright © 2021 林博仁(Buo-ren, Lin) <[email protected]>
10+
# Copyright 2023 林博仁(Buo-ren, Lin) <[email protected]>
11+
# SPDX-License-Identifier: CC-BY-SA-4.0 OR LicenseRef-Apache-2.0-If-Not-Used-In-Template-Projects
1312

14-
# Exclude development assets from release archive
13+
# Avoid exporting development files to release archive
1514
/.* export-ignore
16-
/continuous-integration/ export-ignore
15+
/continuous-integration export-ignore
1716

18-
# Exclude development assets exclusive licenses
19-
/LICENSES/WTFPL.* export-ignore
17+
# Keep editorconfig for ease of editing of product files
18+
/.editorconfig -export-ignore
2019

21-
# Include dep5 declaration file in release archive
20+
# Keep REUSE DEP5 declaration file in the release archive for legal
21+
# conformance
2222
/.reuse/ -export-ignore
23+
/.reuse/* export-ignore
24+
/.reuse/dep5 -export-ignore

.github/workflows/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# workflows
2+
3+
Workflow definition files of the [GitHub Actions Continuous Integration(CI) service](https://github.com/features/actions)
4+
5+
## Reference
6+
7+
* [Features • GitHub Actions](https://github.com/features/actions)
8+
Product page
9+
* [GitHub Actions Documentation - GitHub Docs](https://docs.github.com/en/actions)
10+
Official documentation
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# GitHub Actions workflow for checking potential problems in the project
2+
#
3+
# References:
4+
#
5+
# * Workflow syntax for GitHub Actions - GitHub Docs
6+
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
7+
#
8+
# Copyright 2022 林博仁(Buo-ren, Lin) <[email protected]>
9+
# SPDX-License-Identifier: CC-BY-SA-4.0
10+
name: Check potential problems in the project
11+
on:
12+
push:
13+
branches:
14+
- '**'
15+
jobs:
16+
check-using-precommit:
17+
name: Check potential problems using pre-commit
18+
runs-on: ubuntu-22.04
19+
env:
20+
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
21+
PRE_COMMIT_HOME: ${{ github.workspace }}/.cache/pre-commit
22+
SHELLCHECK_DIR: ${{ github.workspace }}/.cache/shellcheck-stable
23+
steps:
24+
- name: Check out content from the Git repository
25+
uses: actions/checkout@v4
26+
27+
- name: Configure PyPI data cache to speed up continuous integration
28+
uses: actions/cache@v3
29+
with:
30+
key: ${{ runner.os }}-pip
31+
path: ${{ env.PIP_CACHE_DIR }}
32+
33+
- name: >-
34+
Configure pre-commit data cache to speed up continuous integration
35+
uses: actions/cache@v3
36+
with:
37+
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
38+
path: ${{ env.PRE_COMMIT_HOME }}
39+
40+
- name: >-
41+
Configure pre-built ShellCheck cache to speed up continuous integration
42+
uses: actions/cache@v3
43+
with:
44+
key: ${{ runner.os }}-${{ runner.arch }}-shellcheck
45+
path: ${{ env.SHELLCHECK_DIR }}
46+
47+
- name: >-
48+
Patch the sudo security policy so that programs run via sudo
49+
will recognize environment variables predefined by GitHub
50+
run: sudo ./continuous-integration/patch-github-actions-sudo-security-policy.sh
51+
52+
- name: Run the static analysis programs
53+
run: |
54+
sudo ./continuous-integration/do-static-analysis.install-system-deps.sh
55+
./continuous-integration/do-static-analysis.sh
56+
57+
- name: Send CI result notification to the Telegram channel
58+
uses: yanzay/[email protected]
59+
if: always()
60+
with:
61+
chat: '@the_common_ci_results'
62+
token: ${{ secrets.telegram_bot_api_token_ci }}
63+
status: ${{ job.status }}

.github/workflows/release.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Release product and their build aritfacts
2+
#
3+
# References:
4+
#
5+
# * Workflow syntax for GitHub Actions - GitHub Docs
6+
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
7+
#
8+
# Copyright 2023 林博仁(Buo-ren, Lin) <[email protected]>
9+
# SPDX-License-Identifier: CC-BY-SA-4.0
10+
name: Release product and their build aritfacts
11+
on:
12+
push:
13+
tags:
14+
- v*.*.*
15+
16+
jobs:
17+
release:
18+
name: Release product and their build aritfacts
19+
runs-on: ubuntu-20.04
20+
steps:
21+
- name: Check out content from the Git repository
22+
uses: actions/checkout@v4
23+
with:
24+
# Increase fetch depth if you may have more than this amount
25+
# of revisions between releases
26+
fetch-depth: 100
27+
28+
# Fetch tags as well to generate detailed changes between two releases
29+
# WORKAROUND: Adding this option triggers actions/checkout#1467
30+
#fetch-tags: true
31+
32+
- name: >-
33+
WORKAROUND: Fetch tags that points to the revisions
34+
checked-out(actions/checkout#1467)
35+
run: |-
36+
git fetch \
37+
--prune \
38+
--prune-tags \
39+
--force \
40+
--depth=100 \
41+
--no-recurse-submodules
42+
43+
- name: Determine the project identifier
44+
run: printf "project_id=${GITHUB_REPOSITORY##*/}\\n" >> $GITHUB_ENV
45+
46+
- name: Determine the name of the Git tag
47+
run: printf "release_tag=${GITHUB_REF##*/}\\n" >> $GITHUB_ENV
48+
49+
- name: Determine the release version string
50+
run: printf "release_version=${release_tag#v}\\n" >> $GITHUB_ENV
51+
52+
- name: Determine the release identifier
53+
run: printf "release_id=${project_id}-${release_version}\\n" >> $GITHUB_ENV
54+
55+
- name: >-
56+
Patch the sudo security policy so that programs run via sudo
57+
will recognize environment variables predefined by GitHub
58+
run: sudo ./continuous-integration/patch-github-actions-sudo-security-policy.sh
59+
60+
- name: Generate the release archive
61+
run: |-
62+
sudo ./continuous-integration/generate-build-artifacts.install-system-deps.sh
63+
./continuous-integration/generate-build-artifacts.sh
64+
65+
- name: Generate the release description
66+
run: ./continuous-integration/generate-release-description.sh
67+
68+
- name: Publish the release archive to the GitHub Releases
69+
uses: softprops/[email protected]
70+
with:
71+
name: ${{ env.project_id }} ${{ env.release_version }}
72+
files: |
73+
${{ env.release_id }}.tar*
74+
body_path: .detailed_changes

.gitignore

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# Exclude files not suitable for version tracking in Git
55
#
66
# This file is based on The Common .gitignore Templates
7-
# https://github.com/Lin-Buo-Ren/common-gitignore
8-
# Copyright 2021 林博仁(Buo-ren, Lin) <[email protected]>
9-
# SPDX-License-Identifier: CC-BY-SA-4.0
7+
# https://github.com/the-common/gitignore-templates
8+
#
9+
# Copyright 2022 林博仁(Buo-ren, Lin) <[email protected]>
10+
# SPDX-License-Identifier: CC-BY-SA-4.0 OR LicenseRef-Apache-2.0-If-Not-Used-In-Template-Projects
1011

1112
# Don't track regular Unix hidden files
1213
.*
@@ -30,19 +31,22 @@
3031
# https://docs.drone.io/
3132
!.drone.yml
3233

34+
# Do track yamllint configuration files
35+
!.yamllint
36+
3337
# Do track REUSE configuration files
38+
# https://reuse.software/
3439
!.reuse/
3540

36-
# Do track yamllint configuration files
37-
!.yamllint
41+
# Do track GitLab CI configuration file
42+
!/.gitlab-ci.yml
3843

3944
# Don't track common backup filename extensions
4045
*~
41-
*.bk*
4246
*.bak*
4347
*.backup*
44-
*.old*
4548
*.bk*
49+
*.old*
4650
*.orig*
4751

4852
## Don't track common archive files
@@ -60,18 +64,27 @@
6064

6165
# Don't track common export formats from Markdown
6266
*.doc?
63-
*.pdf
6467
*.htm?
68+
*.pdf
6569

6670
# Don't track common program output logs
71+
*.err
72+
*.error
6773
*.log
6874
*.out
6975
*.output
70-
*.err
71-
*.error
7276

7377
# Don't track compiled Python code caches
7478
*.pyc
7579

7680
# Don't track Vagrant runtime directories
7781
.vagrant/
82+
83+
# Don't track GNU gettext message catalog template
84+
*.pot
85+
86+
# Don't track GNU gettext machine-readable message catalogs
87+
*.mo
88+
89+
# Don't track continuous integration virtual environments
90+
/continuous-integration/venv/

.gitlab-ci.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# GitLab CI configuration file
2+
#
3+
# References:
4+
#
5+
# * `.gitlab-ci.yml` keyword reference | GitLab
6+
# https://docs.gitlab.com/ee/ci/yaml/
7+
#
8+
# Copyright 2023 林博仁(Buo-ren, Lin) <[email protected]>
9+
# SPDX-License-Identifier: CC-BY-SA-4.0 OR LicenseRef-Apache-2.0-If-Not-Used-In-Template-Projects
10+
do-static-analysis:
11+
stage: test
12+
rules:
13+
- if: $CI_COMMIT_TAG == null
14+
needs: []
15+
image: ubuntu:22.04
16+
variables:
17+
PIP_CACHE_DIR: ${CI_PROJECT_DIR}/.cache/pip
18+
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
19+
SHELLCHECK_DIR: ${CI_PROJECT_DIR}/.cache/shellcheck-stable
20+
cache:
21+
# Enable per-job and per-branch caching
22+
key: $CI_JOB_NAME-$CI_COMMIT_REF_SLUG
23+
paths:
24+
- ${PIP_CACHE_DIR}
25+
- ${PRE_COMMIT_HOME}
26+
- ${SHELLCHECK_DIR}
27+
28+
script:
29+
- ./continuous-integration/do-static-analysis.install-system-deps.sh
30+
- ./continuous-integration/do-static-analysis.sh
31+
32+
generate-build-artifacts:
33+
stage: build
34+
rules:
35+
- if: $CI_COMMIT_TAG
36+
needs: []
37+
image: ubuntu:22.04
38+
artifacts:
39+
paths:
40+
- ${CI_PROJECT_NAME}-*.tar*
41+
script:
42+
- ./continuous-integration/generate-build-artifacts.install-system-deps.sh
43+
- ./continuous-integration/generate-build-artifacts.sh
44+
45+
upload-release-assets:
46+
stage: deploy
47+
rules:
48+
- if: $CI_COMMIT_TAG
49+
needs:
50+
- generate-build-artifacts
51+
image: curlimages/curl:latest
52+
script:
53+
- ./continuous-integration/upload-gitlab-generic-packages.sh
54+
55+
create-release:
56+
stage: deploy
57+
rules:
58+
- if: $CI_COMMIT_TAG
59+
needs:
60+
- generate-build-artifacts
61+
- upload-release-assets
62+
image: registry.gitlab.com/gitlab-org/release-cli:latest
63+
script:
64+
- apk add bash git
65+
- ./continuous-integration/generate-release-description.sh
66+
- ./continuous-integration/create-gitlab-release.sh

0 commit comments

Comments
 (0)