Skip to content

Commit 59a7541

Browse files
committed
Use composite steps action instead of docker action; tidy ups.
1 parent ba9aca4 commit 59a7541

5 files changed

Lines changed: 30 additions & 15 deletions

File tree

.github/workflows/status_check.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@ name: Run precommit checks on self
22
on: pull_request
33
jobs:
44
precommit-check:
5-
runs-on: ubuntu-latest
5+
runs-on: ${{ matrix.os }}
6+
strategy:
7+
matrix:
8+
os: [ ubuntu-latest, macos-latest, windows-latest]
69
steps:
710
- uses: actions/checkout@v2
811
with:
912
ref: ${{ github.head_ref }}
1013
fetch-depth: 0
11-
- uses: ccdc-opensource/commit-hooks@precommit_action
14+
- uses: actions/setup-python@v2
15+
with:
16+
python-version: "3.7"
17+
- uses: ccdc-opensource/commit-hooks@composite_steps

Dockerfile

Lines changed: 0 additions & 6 deletions
This file was deleted.

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This repository contains files that can be used as a github action and local
22
git hooks.
33

4-
It does a few checks on source codes to ensure compliance with some general
4+
It does a few checks on source code to ensure compliance with some general
55
CCDC coding standard.
66

77
The commit will be flagged if it includes certain text files with:
@@ -31,13 +31,19 @@ on:
3131
branches: [ main ]
3232
jobs:
3333
Pull-request-files-check:
34-
runs-on: ubuntu-latest
34+
runs-on: ${{ matrix.os }}
35+
strategy:
36+
matrix:
37+
os: [ ubuntu-latest, macos-latest, windows-latest]
3538
steps:
3639
- uses: actions/checkout@v2
3740
with:
3841
ref: ${{ github.head_ref }}
3942
fetch-depth: 0
40-
- uses: ccdc-opensource/commit-hooks@v1
43+
- uses: actions/setup-python@v2
44+
with:
45+
python-version: "3.7"
46+
- uses: ccdc-opensource/commit-hooks@v2
4147
```
4248
4349
# commit-hooks

action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ name: CCDC File Checks
22
author: CCDC
33
description: Check changed files for compliance
44
runs:
5-
using: "docker"
6-
image: "Dockerfile"
5+
using: "composite"
6+
steps:
7+
- run: python3 $GITHUB_ACTION_PATH/main.py
8+
shell: bash
79
branding:
810
icon: 'check-square'
911
color: 'green'

main/githooks.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# Absolute file size limit (in MB) - it's 100MB on github.com
1919
HARD_SIZE_THRESHOLD = 99.0
2020
# Internal file size limit (in MB) - allow if commit message includes marker
21-
SOFT_SIZE_THRESHOLD = 60.0
21+
SOFT_SIZE_THRESHOLD = 5.0
2222
# Large file marker in commit message
2323
LARGE_FILE_MARKER = 'LARGE_FILE'
2424
# Check file content if it has these extensions
@@ -102,7 +102,14 @@ def get_branch():
102102

103103

104104
def get_sha():
105-
'''Get the commit sha'''
105+
'''Get the commit sha
106+
107+
The sha of the branch we are interested in, ie. the tip of the branch that
108+
is pushed or to be merged to main.
109+
110+
GITHUB_SHA cannot be used because in a pull request it gives the sha of the
111+
fake merge commit.
112+
'''
106113
return _get_output(f'git rev-parse {get_branch()}')
107114

108115

0 commit comments

Comments
 (0)