From 8867d2263c1c6ebe08617b708c965f04eb1543da Mon Sep 17 00:00:00 2001 From: Wisaroot Lertthaweedech Date: Thu, 10 Jul 2025 19:25:34 +0700 Subject: [PATCH 1/6] feat: add github actions --- .github/workflows/ci.yml | 51 ++++++-------------- .github/workflows/semantic-pull-request.yaml | 19 ++++++++ LICENSE | 9 ++++ Makefile | 8 +-- README.md | 44 ++++------------- python/setup_pipx.sh | 1 + 6 files changed, 59 insertions(+), 73 deletions(-) create mode 100644 .github/workflows/semantic-pull-request.yaml create mode 100644 LICENSE diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8ab7f1b..83dc338 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,35 +1,16 @@ -# name: CI - -# on: -# pull_request: -# types: [opened, synchronize, reopened] - -# jobs: -# lint-and-test: -# runs-on: ubuntu-latest - -# steps: -# - uses: actions/checkout@v4 -# with: -# fetch-depth: 0 - -# - name: Setup Node.js -# uses: actions/setup-node@v4 -# with: -# node-version: '22' -# cache: 'npm' - -# - name: Install dependencies -# run: npm install - -# - name: Set up Python -# uses: actions/setup-python@v5 -# with: -# python-version: '3.x' -# cache: 'pip' - -# - name: Run pre-commit -# run: pip install pre-commit && pre-commit run --all-files - -# - name: Run tests -# run: make test +name: Pre-Commit + +on: + pull_request: + push: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 #v4.2.2 + - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5.6.0 + with: + python-version: "3.x" + - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd #v3.0.1 diff --git a/.github/workflows/semantic-pull-request.yaml b/.github/workflows/semantic-pull-request.yaml new file mode 100644 index 0000000..a653070 --- /dev/null +++ b/.github/workflows/semantic-pull-request.yaml @@ -0,0 +1,19 @@ +name: Semantic Pull Request + +on: + pull_request: + branches: [main] + types: [opened, edited, synchronize, reopened] + +permissions: + pull-requests: read + +jobs: + semantic-pull-request: + name: semantic-pull-request + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5.5.3 + name: Validate PR title + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3f04a86 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) 2025-present Wisaroot Lertthaweedech + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Makefile b/Makefile index 1356fb1..0712fbd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -hi: +setup_dev: chmod +x common/update_brew.sh ./common/update_brew.sh @@ -8,8 +8,10 @@ hi: pipx install pre-commit pre-commit install - brew install shfmt - brew install shellcheck + brew install shfmt shellcheck + +assert_setup_dev: + pre-commit run -a lint: find . -type f -name "*.sh" -exec shfmt -w -i 6 {} + diff --git a/README.md b/README.md index 4680907..41e1089 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,16 @@ -# About this template +# Shared Scripts -This template provided common nice to have for every projects under Abacus Digital please feel free to add, edit or delete if you do not using it. +Collection of development setup and utility scripts for macOS environments. -## Dependency - -- [CODEOWNERS](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners) - help controlling whether person or team are owner this repository and permission to approved the pull request -- [dependabot.yaml](https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file) - help auto update the dependency you are using with, also check the dependency CVE -- [pullrequest_template](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/creating-a-pull-request-template-for-your-repository) - help create template format for every one would like to open pull-request to your repository must following the guideline format -- [.dockerignore](https://shisho.dev/blog/posts/how-to-use-dockerignore/) - in case you using docker container ignore non-nessessory file copy to your container -- [.gitignore](https://github.com/github/gitignore) - help to ignore file or folder you don't need to commit to remote repository -- [pre-commit](https://pre-commit.com/) - help to automate checking depend on plugin you are using for make sure everything is ok before commit - -## Pre-commit Guideline - -Pre-commit is a powerful tool that can help you ensure everyone has followed the common practice or linter guidelines you are setting up. It also has other tools to help you, like [Husky](https://typicode.github.io/husky/) Anyway, feel free to remove it if it doesn't match your context - -### Pre-commit will effect locally before commit after you install it - -install pre-commit at local have 2 methods - -Via Home Brew - -```bash -brew install pre-commit -``` - -Via Pip +## Quick Start ```bash -pip install pre-commit +make setup_dev # Install all dependencies and setup development environment +make assert_setup_dev # Validate setup ``` -After iinstall successfully going to root of reposity (same path as `.pre-commit-config.yaml`) - -Run below will install all plugins that specific in the file - -```bash - pre-commit install -``` +## Requirements -Now every are set let `commit`. Readmore [here](https://pre-commit.com/) +- macOS +- Homebrew +- Zsh shell diff --git a/python/setup_pipx.sh b/python/setup_pipx.sh index 3fb9402..9a8997e 100755 --- a/python/setup_pipx.sh +++ b/python/setup_pipx.sh @@ -3,4 +3,5 @@ set -e brew install pipx +pipx upgrade-all pipx ensurepath From fedfdd4a068fcc1907b5c8acc0aef7933ce532df Mon Sep 17 00:00:00 2001 From: Wisaroot Lertthaweedech Date: Thu, 10 Jul 2025 19:30:56 +0700 Subject: [PATCH 2/6] fix: fix ci bug --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83dc338..df82470 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,4 +13,8 @@ jobs: - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5.6.0 with: python-version: "3.x" + - name: Install shfmt and shellcheck + run: sudo apt-get update && sudo apt-get install -y shellcheck shfmt - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd #v3.0.1 + with: + extra_args: --all-files From 8391f4e43d0938a95031e7d56eb8ca85c7cb716d Mon Sep 17 00:00:00 2001 From: Wisaroot Lertthaweedech Date: Thu, 10 Jul 2025 19:35:30 +0700 Subject: [PATCH 3/6] fix: fix ci bug --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df82470..afac1cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,18 @@ jobs: - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5.6.0 with: python-version: "3.x" + cache: pip + - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + with: + path: ~/.cache/pre-commit + key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + id: apt-cache + with: + path: /var/cache/apt + key: apt-${{ runner.os }}-shellcheck-shfmt - name: Install shfmt and shellcheck + if: steps.apt-cache.outputs.cache-hit != 'true' run: sudo apt-get update && sudo apt-get install -y shellcheck shfmt - uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd #v3.0.1 with: From f669f06c286d00eb8c0a8bf948e94febd442f215 Mon Sep 17 00:00:00 2001 From: Wisaroot Lertthaweedech Date: Thu, 10 Jul 2025 19:37:16 +0700 Subject: [PATCH 4/6] fix: fix ci bug --- .github/dependabot.yml | 20 ++++++-------------- .github/workflows/ci.yml | 4 ++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index aadd919..80f5a4b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,16 +1,8 @@ version: 2 updates: - # Enable version updates for npm - - package-ecosystem: 'npm' - directory: '/' - schedule: - interval: 'weekly' - open-pull-requests-limit: 10 - versioning-strategy: auto - - # Enable version updates for GitHub Actions - - package-ecosystem: 'github-actions' - directory: '/' - schedule: - interval: 'weekly' - open-pull-requests-limit: 10 + # Enable version updates for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + open-pull-requests-limit: 10 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index afac1cc..786b51b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,11 +14,11 @@ jobs: with: python-version: "3.x" cache: pip - - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4.2.3 with: path: ~/.cache/pre-commit key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - - uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a #v4.1.2 + - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4.2.3 id: apt-cache with: path: /var/cache/apt From d918dd39a6ce10497bc5098a0214906f08240b88 Mon Sep 17 00:00:00 2001 From: Wisaroot Lertthaweedech Date: Thu, 10 Jul 2025 19:38:42 +0700 Subject: [PATCH 5/6] fix: fix ci bug --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 786b51b..6a403f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,6 @@ jobs: - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5.6.0 with: python-version: "3.x" - cache: pip - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4.2.3 with: path: ~/.cache/pre-commit From bdcc8820830b775de62d955c39ba336b7258d77d Mon Sep 17 00:00:00 2001 From: Wisaroot Lertthaweedech Date: Thu, 10 Jul 2025 19:42:02 +0700 Subject: [PATCH 6/6] fix: fix ci bug --- .github/workflows/ci.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a403f6..721221b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,15 +13,6 @@ jobs: - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 #v5.6.0 with: python-version: "3.x" - - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4.2.3 - with: - path: ~/.cache/pre-commit - key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - - uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 #v4.2.3 - id: apt-cache - with: - path: /var/cache/apt - key: apt-${{ runner.os }}-shellcheck-shfmt - name: Install shfmt and shellcheck if: steps.apt-cache.outputs.cache-hit != 'true' run: sudo apt-get update && sudo apt-get install -y shellcheck shfmt