Skip to content

Commit

Permalink
ci(pre-commit): adding pre-commit for better devex (#5)
Browse files Browse the repository at this point in the history
* ci(pre-commit): adding pre-commit for better devex

a local pre-commit step will run `make run` ensuring that existing ci/cd is utilised

* ci(workflow-and-repo-settings): updating workflow triggers

testing out settings.yaml
  • Loading branch information
shanilhirani committed Jul 12, 2024
1 parent 88ca913 commit 4ac22c0
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 62 deletions.
28 changes: 28 additions & 0 deletions .github/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
repository:
name: "go-credly"
description: "Go Credly - Programmatically fetch your Credly badges for use with Portfolio"
topics: "credly,go"
private: false
has_issues: true
has_projects: false
has_wiki: false
has_downloads: false
default_branch: main
allow_squash_merge: true
allow_merge_commit: true
allow_rebase_merge: true
delete_branch_on_merge: true

branches:
- name: main
protection:
required_pull_request_reviews:
required_approving_review_count: 1
dismiss_stale_reviews: true
require_code_owner_reviews: false
required_status_checks:
strict: true
contexts:
- ci
enforce_admins: true
restrictions: null
16 changes: 12 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@ name: build

on:
push:
branches: [ main ]
branches:
- main
- feat/*
- hotfix/*
- bugfix/*
pull_request:
branches: [ main ]
branches:
- main
- feat/*
- hotfix/*
- bugfix/*
workflow_dispatch:

jobs:
ci:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -22,7 +30,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: "1.22"

- name: Build
run: make ci
Expand Down
64 changes: 32 additions & 32 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches: [main]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [main]
schedule:
- cron: '11 0 * * 5'
- cron: "11 0 * * 5"
workflow_dispatch:

jobs:
Expand All @@ -22,44 +22,44 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'go' ]
language: ["go"]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.22'
- uses: actions/setup-go@v5
with:
go-version: "1.22"

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: release
on:
push:
tags:
- 'v*'
- "v*"
workflow_dispatch:

jobs:
Expand All @@ -19,7 +19,7 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: '1.22'
go-version: "1.22"

- run: make inst

Expand All @@ -30,7 +30,7 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- run: goreleaser release
- run: goreleaser release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
22 changes: 11 additions & 11 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ archives:
format: zip
dockers:
- image_templates:
- "ghcr.io/shanilhirani/go-credly:latest"
- "ghcr.io/shanilhirani/go-credly:{{ .Major }}"
- "ghcr.io/shanilhirani/go-credly:{{ .Major }}.{{ .Minor }}"
- "ghcr.io/shanilhirani/go-credly:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
- "ghcr.io/shanilhirani/go-credly:latest"
- "ghcr.io/shanilhirani/go-credly:{{ .Major }}"
- "ghcr.io/shanilhirani/go-credly:{{ .Major }}.{{ .Minor }}"
- "ghcr.io/shanilhirani/go-credly:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
build_flag_templates:
- "--pull"
# OCI annotations: https://github.com/opencontainers/image-spec/blob/main/annotations.md
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--pull"
# OCI annotations: https://github.com/opencontainers/image-spec/blob/main/annotations.md
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
release:
github:
name_template: "{{.Version}}"
Expand Down
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: trailing-whitespace
args:
- "--markdown-linebreak-ext=md"
- id: mixed-line-ending
args:
- "--fix=auto"
- id: check-case-conflict
- id: check-merge-conflict
- id: check-json
exclude: ^.vscode/
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
- id: no-commit-to-branch
- repo: "https://github.com/pre-commit/mirrors-prettier"
rev: v3.0.0
hooks:
- id: prettier
stages: [commit]
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.5.3
hooks:
- id: commitizen
- id: commitizen-branch
stages: [push]
- repo: local
hooks:
- id: make-all
name: make-all
description: this will run `make all`
entry: .pre-commit-scripts/make_all.sh
language: script
7 changes: 7 additions & 0 deletions .pre-commit-scripts/make_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
set -ev

echo "Initiate Make All"
make all
echo "Make finished"

22 changes: 11 additions & 11 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community.
Examples of behavior that contributes to a positive environment for our
community include:

* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
- Focusing on what is best not just for us as individuals, but for the
overall community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
- The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
- Other conduct which could reasonably be considered inappropriate in a
professional setting

## Enforcement Responsibilities
Expand Down Expand Up @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban.
### 4. Permanent Ban

**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.

**Consequence**: A permanent ban from any sort of public interaction within
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Go Credly is a Go App which enables users to obtain Certification Badges earned
If your Credly Badges are made public then all you need is your Credly `username` and you'll be able to pull your badges programmatically.

### Use case

- You could use this tool to dynamically update a CV/Resume, Portfolios and Personal Websites using a Github Action, or just running the binary on a cron.

## Prerequisites
Expand All @@ -39,7 +40,7 @@ To run the application, execute the following command:

`go run main.go <yourcredlyusername>`

Then *go-credly* will attempt to fetch data from Credly's API and return the result in JSON to standard out.
Then _go-credly_ will attempt to fetch data from Credly's API and return the result in JSON to standard out.

## Configuration

Expand Down
26 changes: 26 additions & 0 deletions cz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
commitizen:
name: cz_conventional_commits
version: 0.0.1
tag_format: $version
style:
- - qmark
- fg:#ff9d00 bold
- - question
- bold
- - answer
- fg:#ff9d00 bold
- - pointer
- fg:#ff9d00 bold
- - highlighted
- fg:#ff9d00 bold
- - selected
- fg:#cc5454
- - separator
- fg:#cc5454
- - instruction
- ""
- - text
- ""
- - disabled
- fg:#858585 italic

0 comments on commit 4ac22c0

Please sign in to comment.