3 Commits

Author SHA1 Message Date
Iain Sproat e4bde6ce7c fix(pre-commit): remove deprecated stage name & port to GitHub Actions (#5)
Release pipeline / Precommit check (push) Has been cancelled
2026-04-03 10:31:16 +01:00
Iain Sproat 20883c95e8 fix(ggshield-not-ci): correct logic and print when skipping (#4) 2022-08-25 18:00:42 +01:00
Iain Sproat 4d00b7d5b6 Adds a pre-commit config (#3)
- adds a pre-commit config
- includes prettier formatting configuration
- fixes title in README
- adds a CircleCI config
- sets default pre-commit stage to commit
2022-08-25 13:04:22 +01:00
9 changed files with 88 additions and 132 deletions
-77
View File
@@ -1,77 +0,0 @@
name: Update issue Status
on:
issues:
types: [closed]
jobs:
update_issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ORGANIZATION: specklesystems
PROJECT_NUMBER: 9
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
settings
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
echo "$PROJECT_ID"
echo "$STATUS_FIELD_ID"
echo 'DONE_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .settings | fromjson | .options[] | select(.name== "Done") | .id' project_data.json) >> $GITHUB_ENV
echo "$DONE_ID"
- name: Add Issue to project #it's already in the project, but we do this to get its node id!
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $id:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $id}) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f id=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
- name: Update Status
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $status:ID!, $id:ID!, $value:String!) {
set_status: updateProjectNextItemField(
input: {
projectId: $project
itemId: $id
fieldId: $status
value: $value
}
) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f status=$STATUS_FIELD_ID -f id=$ITEM_ID -f value=${{ env.DONE_ID }}
-50
View File
@@ -1,50 +0,0 @@
name: Move new issues into Project
on:
issues:
types: [opened]
jobs:
track_issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ORGANIZATION: specklesystems
PROJECT_NUMBER: 9
run: |
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
query($org: String!, $number: Int!) {
organization(login: $org){
projectNext(number: $number) {
id
fields(first:20) {
nodes {
id
name
settings
}
}
}
}
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
- name: Add Issue to project
env:
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
ISSUE_ID: ${{ github.event.issue.node_id }}
run: |
item_id="$( gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
mutation($project:ID!, $id:ID!) {
addProjectNextItem(input: {projectId: $project, contentId: $id}) {
projectNextItem {
id
}
}
}' -f project=$PROJECT_ID -f id=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
+37
View File
@@ -0,0 +1,37 @@
name: Release pipeline
on:
push:
branches:
- '**' # all branches
tags:
- "[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
permissions: {} # purposefully empty by default at workflow level, explicitly overridden for specific jobs below
jobs:
pre-commit:
name: Precommit check
runs-on: blacksmith-4vcpu-ubuntu-2404
permissions:
contents: read
packages: read # to be able to pull the pre-commit-runner image from ghcr.io
container:
image: ghcr.io/specklesystems/pre-commit-runner:latest # zizmor: ignore[unpinned-images] Speckle own this image repository
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
fetch-depth: 0
persist-credentials: false
- run: git config --global --add safe.directory $PWD
- name: Set precommit
run: pre-commit install-hooks --config ./.pre-commit-config.yaml
- name: Run precommit
run: pre-commit run --all-files --config ./.pre-commit-config.yaml
- name: Diff on failure
if: failure()
run: git --no-pager diff
+28
View File
@@ -0,0 +1,28 @@
default_stages:
- 'pre-commit'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v6.0.0'
hooks:
- id: check-yaml
- id: check-merge-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-vcs-permalinks
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/syntaqx/git-hooks
rev: 'v0.0.18'
hooks:
- id: forbid-binary
- repo: https://github.com/pre-commit/pre-commit
rev: 'v4.5.1'
hooks:
- id: validate_manifest
ci:
autoupdate_schedule: quarterly
+1 -1
View File
@@ -1,6 +1,6 @@
- id: ggshield-not-ci
name: GitGuardian Shield (pre-commit)
description: Runs ggshield in non-CI environments to detect hardcoded secrets, security vulnerabilities and policy breaks.
stages: [commit]
stages: [pre-commit]
entry: hooks/ggshield-not-ci.sh
language: script
+1
View File
@@ -0,0 +1 @@
.github/
+11
View File
@@ -0,0 +1,11 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"endOfLine": "auto",
"bracketSpacing": true,
"vueIndentScriptAndStyle": false,
"htmlWhitespaceSensitivity": "ignore",
"printWidth": 88,
"singleQuote": true
}
+7 -3
View File
@@ -1,4 +1,4 @@
# Speckle Repo Management Templates
# Speckle Pre-Commit Hooks
[![Twitter Follow](https://img.shields.io/twitter/follow/SpeckleSystems?style=social)](https://twitter.com/SpeckleSystems) [![Community forum users](https://img.shields.io/discourse/users?server=https%3A%2F%2Fdiscourse.speckle.works&style=flat-square&logo=discourse&logoColor=white)](https://discourse.speckle.works) [![website](https://img.shields.io/badge/https://-speckle.systems-royalblue?style=flat-square)](https://speckle.systems) [![docs](https://img.shields.io/badge/docs-speckle.guide-orange?style=flat-square&logo=read-the-docs&logoColor=white)](https://speckle.guide/dev/)
@@ -17,6 +17,7 @@ Comprehensive developer and user documentation for Speckle can be found in our:
## Usage
1. Add the following to your `.pre-commit-config.yaml` file:
```
- repo: https://github.com/specklesystems/pre-commit
rev: '0.1.0'
@@ -27,11 +28,14 @@ Comprehensive developer and user documentation for Speckle can be found in our:
## Developing & Debugging
1. install:
- `git`
- `pre-commit`
- `git`
- `pre-commit`
1. Git clone this repository. Detailed steps on how to do that can be found on [GitHub's documentation](https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls).
1. In a terminal, `cd` into a directory containing code that you wish to try the pre-commit hook on. e.g. Speckle's `speckle-server` repository.
1. Run the following command to run a pre-commit hook directly from this repository. Replace `<pre-commit hook to run>` with the name of the hook you wish to run:
```shell
pre-commit try-repo ./path/to/cloned/specklesystems/pre-commit <pre-commit hook to run>
```
+3 -1
View File
@@ -1,6 +1,8 @@
#!/usr/bin/env bash
set -eo pipefail
if [[ ! -z "${CI}"} ]]; then
if [[ -z "${CI}" ]]; then
ggshield secret scan pre-commit
else
echo "Detected that this script is running in a CI environment, so skipping GitGuardian ggshield"
fi