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

FEATURE: git-hooks + Startersteps.md #3

Merged
merged 5 commits into from
Aug 6, 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
9 changes: 9 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.

echo "Hello, world! I am destruction!"
exit 1
13 changes: 13 additions & 0 deletions .github/workflows/startersteps-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Startersteps.md Check
on: [push]
jobs:
check-for-Startersteps-file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check if Startersteps.md exists
run: |
if [[ -f "Startersteps.md" ]]; then
echo "Make sure to complete all the steps in Startersteps.md, then delete that file and this workflow!"
exit 1
fi
29 changes: 29 additions & 0 deletions .github/workflows/todoon-fail.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Assert No TODO/FIXMEs with TODO-or-not

on:
workflow_dispatch:
jobs:
run_todoon:
runs-on: ubuntu-latest
environment: testing
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11.7
uses: actions/setup-python@v3
with:
python-version: "3.11.7"
- name: Install TODO-or-not
run: |
python -m pip install --upgrade pip
python -m pip install todo-or-not
- name: Generate GH Token for todoon app
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: 853479
- name: Run TODO-or-not
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
echo "Fail the workflow if any TODOs or FIXMEs are discovered"
todoon
15 changes: 15 additions & 0 deletions Starterfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ tools:
install: npm install -g pnpm
uninstall: npm uninstall -g pnpm
check: pnpm --version
git-hooks:
depends_on: nodejs
# Only works with git>=2.9.0
scripts:
windows:
check: |
npm install semver
./scripts/check-git.bat
npm uninstall semver
check: |
npm install semver
bash ./scripts/check-git.bash
npm uninstall semver
install: git config --local core.hooksPath .githooks/
uninstall: git config --local --unset core.hooksPath

modules:
postgresql:
Expand Down
36 changes: 36 additions & 0 deletions Startersteps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Set up GitHub apps

## TODO-Or-Not

### Install at this repository

1. [Go to the _TODO-Or-Not_ app page](https://github.com/apps/todo-or-not)
2. Select the owner of this repository (`${NEW_OWNER}`)
3. Install for **"Only select repositories"**
4. **"Search for a repository"** named `${NEW_OWNER}/${NEW_REPO}`
5. **"Install & Authorize"**
6. [Go to **"Settings > GitHub Apps"** in this repository](https://github.com/${NEW_OWNER}/${NEW_REPO}/settings/installations)

<!--

# Set up GitHub environments

## [Go to environment settings](https://github.com/${NEW_OWNER}/${NEW_REPO_NAME}/settings/environments)

## testing

### Create new environment

1. Create a **"New environment"**
2. **"Name"** it `testing` (case-sensitive)
3. **"Configure environment"**

### Add environment variables

1. **"Add environment variable"**"

### Add environment secrets

1. **"Add environment secret"**"

-->
11 changes: 11 additions & 0 deletions scripts/check-git.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
REQUIRED_VERSION="2.9.0"
VERSION_STRING=$(git --version)
GIT_VERSION=$(echo $VERSION_STRING | awk '{print $3}')

if [[ $(semver "$GIT_VERSION" -r ">=$REQUIRED_VERSION") ]]; then
echo "Git version is greater than or equal to $REQUIRED_VERSION"
else
echo "Git version is less than $REQUIRED_VERSION"
exit 1
fi
6 changes: 6 additions & 0 deletions scripts/check-git.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
set REQUIRED_VERSION=2.9.0
for /f "tokens=3 USEBACKQ" %%F in (`git --version`) do (
set GIT_VERSION=%%F
)
node -e " var semver = require('semver'); var gitVersion = '%GIT_VERSION%'; gitVersion = gitVersion.split('.').slice(0, 3).join('.'); if(semver.gte(gitVersion, '%REQUIRED_VERSION%')) console.log('Git version is greater than or equal to %REQUIRED_VERSION% (%GIT_VERSION%)'); else console.log('Git version is less than %REQUIRED_VERSION% (%GIT_VERSION%)'); process.exit(1);"
Loading