Skip to content

Commit 766a56c

Browse files
committed
[py|ts] Add github actions checker
1 parent 6f56342 commit 766a56c

29 files changed

+6183
-123
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: ./typescript
5+
schedule:
6+
interval: daily
7+
8+
- package-ecosystem: npm
9+
directory: ./typescript
10+
schedule:
11+
interval: daily

.github/workflows/build.yml

+34-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,39 @@ name: Build
22
on: [push, pull_request]
33

44
jobs:
5-
build:
5+
build-typescript:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout main
9+
uses: actions/checkout@v3
10+
11+
- name: npm install
12+
working-directory: ./typescript
13+
run: |
14+
npm install
15+
- name: npm run all
16+
working-directory: ./typescript
17+
run: |
18+
npm run all
19+
- name: Commit Check (shipped SimpleTag)
20+
uses: ./
21+
with:
22+
validator: "SimpleTag"
23+
- name: Commit Check (shipped RegEx)
24+
if: success() || failure()
25+
uses: ./
26+
with:
27+
validator: "RegEx"
28+
options: |
29+
>any<
30+
>any<
31+
- name: Commit Check (local)
32+
if: success() || failure()
33+
uses: ./
34+
with:
35+
validator_file: "typescript/example/simpleTag.mjs"
36+
37+
build-python:
638
name: ${{ matrix.os }} Python ${{ matrix.python-version }}
739
runs-on: ${{ matrix.os }}
840
strategy:
@@ -55,6 +87,6 @@ jobs:
5587
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10.0' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
5688
uses: pypa/gh-action-pypi-publish@release/v1
5789
with:
58-
packages_dir: python/dist
90+
packages_dir: ./python/dist
5991
user: __token__
6092
password: ${{ secrets.PYPI_TOKEN }}

.github/workflows/commit_naming_python.yml renamed to .github/workflows/commit_check.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Commit Naming (Python)
1+
name: Commit Check
22
on:
33
pull_request:
44
branches:
@@ -8,8 +8,8 @@ on:
88
- main
99

1010
jobs:
11-
naming:
12-
name: Commit Naming
11+
commit-check-python:
12+
name: Commit Check (Python)
1313
runs-on: ubuntu-latest
1414
container: python:alpine
1515
steps:
@@ -36,17 +36,18 @@ jobs:
3636
uses: actions/checkout@v3
3737

3838
- name: Install gitcc
39+
working-directory: ./python
3940
run: |
4041
pip install .
4142
4243
- name: Check commits (Pull Request)
4344
if: ${{ github.event_name == 'pull_request' }}
4445
run: |
4546
git config --global --add safe.directory `pwd`
46-
gitcc history --verbose ./
47+
gitcc --validator gitcc.validation.SimpleTag history --verbose ./
4748
4849
- name: Check commit (Push)
4950
if: ${{ github.event_name == 'push' }}
5051
run: |
5152
git config --global --add safe.directory `pwd`
52-
gitcc commit ./
53+
gitcc --validator gitcc.validation.SimpleTag commit ./
+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Deploy GitHub Actions
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
env:
8+
gh_actions_git_path: './gh-actions/'
9+
main_git_path: './main/'
10+
11+
jobs:
12+
deploy-typescript:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout main
16+
uses: actions/checkout@v3
17+
with:
18+
path: ${{ env.main_git_path }}
19+
- name: Checkout gh-actions
20+
uses: actions/checkout@v3
21+
with:
22+
ref: 'gh-actions'
23+
path: ${{ env.gh_actions_git_path }}
24+
25+
- name: npm install
26+
working-directory: ${{ env.main_git_path }}/typescript
27+
run: |
28+
npm install
29+
- name: Build gitcc
30+
working-directory: ${{ env.main_git_path }}/typescript
31+
run: |
32+
npm run build
33+
npm run package
34+
35+
- name: Remove old files
36+
working-directory: ${{ env.gh_actions_git_path }}
37+
run: |
38+
rm -rf ./*
39+
- name: Copy new files
40+
run: |
41+
mkdir -p ${{ env.gh_actions_git_path }}/typescript/dist/
42+
cp -rf ${{ env.main_git_path }}/typescript/dist* ${{ env.gh_actions_git_path }}/typescript/
43+
cp -rf ${{ env.main_git_path }}/action.yml ${{ env.gh_actions_git_path }}
44+
- name: Push new files
45+
working-directory: ${{ env.gh_actions_git_path }}
46+
run: |
47+
git config user.name github-actions
48+
git config user.email [email protected]
49+
git add .
50+
git diff-index --quiet HEAD || git commit -am "[actions] Build of ${{ github.sha }}"
51+
git push
52+
53+
commit-check:
54+
name: Commit Check
55+
runs-on: ubuntu-latest
56+
needs: deploy-typescript
57+
steps:
58+
- name: Commit Check
59+
uses: IceflowRE/gitcc@gh-actions
60+
with:
61+
validator: "SimpleTag"

.gitignore

-90
Original file line numberDiff line numberDiff line change
@@ -1,91 +1 @@
11
.idea/
2-
3-
# Byte-compiled / optimized / DLL files
4-
__pycache__/
5-
*.py[cod]
6-
*$py.class
7-
8-
# C extensions
9-
*.so
10-
11-
# Distribution / packaging
12-
.Python
13-
env/
14-
build/
15-
develop-eggs/
16-
dist/
17-
downloads/
18-
eggs/
19-
.eggs/
20-
lib/
21-
lib64/
22-
parts/
23-
sdist/
24-
var/
25-
*.egg-info/
26-
.installed.cfg
27-
*.egg
28-
29-
# PyInstaller
30-
# Usually these files are written by a python script from a template
31-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32-
*.manifest
33-
*.spec
34-
35-
# Installer logs
36-
pip-log.txt
37-
pip-delete-this-directory.txt
38-
39-
# Unit test / coverage reports
40-
htmlcov/
41-
.tox/
42-
.coverage
43-
.coverage.*
44-
.cache
45-
nosetests.xml
46-
coverage.xml
47-
*,cover
48-
.hypothesis/
49-
50-
# Translations
51-
*.mo
52-
*.pot
53-
54-
# Django stuff:
55-
*.log
56-
local_settings.py
57-
58-
# Flask stuff:
59-
instance/
60-
.webassets-cache
61-
62-
# Scrapy stuff:
63-
.scrapy
64-
65-
# Sphinx documentation
66-
doc/_build/
67-
68-
# PyBuilder
69-
target/
70-
71-
# IPython Notebook
72-
.ipynb_checkpoints
73-
74-
# pyenv
75-
.python-version
76-
77-
# celery beat schedule file
78-
celerybeat-schedule
79-
80-
# dotenv
81-
.env
82-
83-
# virtualenv
84-
venv/
85-
ENV/
86-
87-
# Spyder project settings
88-
.spyderproject
89-
90-
# Rope project settings
91-
.ropeproject

README.rst

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ GitCC
99

1010
GitCC checks commit messages for certain rules.
1111

12+
1213
GitCC is available as a Python implementation, which provides a CLI and local git hooks.
14+
1315
`Python version <./python/README.rst>`__
14-
For a GitHub Actions implementation, when only used in CI, refer to
15-
`Javascript version <./python/README.rst>`__
1616

17-
----
17+
For use in GitHub Actions refer to
18+
19+
`GitCC GitHub Actions <./typescript/README.rst>`__
1820

1921
Web
2022
===
@@ -29,7 +31,7 @@ Credits
2931
3032

3133
License
32-
-------
34+
=======
3335

3436
Copyright 2021-present Iceflower S ([email protected])
3537

@@ -43,7 +45,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
4345
4446
.. |maintained| image:: https://img.shields.io/badge/maintained-yes-brightgreen.svg
4547

46-
.. |programming language| image:: https://img.shields.io/badge/language-Python_3.10%20/%20Javascript-orange.svg
48+
.. |programming language| image:: https://img.shields.io/badge/language-Python_3.10%20/%20Typescript-orange.svg
4749

4850
.. |license| image:: https://img.shields.io/badge/License-MIT-blue.svg
4951
:target: https://github.com/IceflowRE/gitcc/blob/main/LICENSE.rst

action.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 'GitCC'
2+
description: 'Git commit check based on certain rules.'
3+
author: 'Iceflower S'
4+
inputs:
5+
access_token:
6+
required: false
7+
description: 'Github private access token'
8+
default: ${{ github.token }}
9+
validator_file:
10+
required: false
11+
description: 'filepath to a validator file'
12+
validator:
13+
required: false
14+
description: 'name of a validator which is shipped with GitCC (available: SimpleTag)'
15+
options:
16+
required: false
17+
description: 'each line is passed as an entry of a list to the validator'
18+
runs:
19+
using: 'node16'
20+
main: 'typescript/dist/index.js'

0 commit comments

Comments
 (0)