From 73bbed0dbf54e1e2c02900de70af1371df594d46 Mon Sep 17 00:00:00 2001 From: signature18632 Date: Sun, 17 Aug 2025 07:34:24 +0700 Subject: [PATCH] update ci --- .dockerignore | 1 + .github/CODEOWNERS | 2 + .github/PULL_REQUEST_TEMPLATE.md | 22 +++------ .github/setup/action.yml | 43 +++++++++++++++++ .github/workflows/ci-coverage.yml | 43 +++++++++++++++++ .github/workflows/ci.yml | 69 ++++++++++------------------ .github/workflows/release-on-tag.yml | 26 +++++++++++ 7 files changed, 145 insertions(+), 61 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/setup/action.yml create mode 100644 .github/workflows/ci-coverage.yml create mode 100644 .github/workflows/release-on-tag.yml diff --git a/.dockerignore b/.dockerignore index 24de1c0..e40416c 100644 --- a/.dockerignore +++ b/.dockerignore @@ -17,6 +17,7 @@ out *.local .nvmrc biome.json +coverage # Environment files .env diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..9eda5f7 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +# default code owner +* @signature18632 diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6c0e2a0..78f26e9 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,19 +1,11 @@ -## Summary +Closes # -* **What / Why (Background & Purpose)** +## 🎯 Changes -## Changes +What changes are made in this PR? Is it a feature or a bug fix? -* **Key Changes** (API / JOB / DB, etc.) +## ✅ Checklist -## Checklist - -* [ ] `yarn format` -* [ ] `yarn test` -* [ ] Document any breaking changes -* [ ] Review from a security perspective (no sensitive information) - -## Related - -* Closes # -* Depends on # +- [ ] I have followed the steps listed in the [Contributing guide](https://github.com/InternetMaximalism/intmax2-function/blob/main/CONTRIBUTING.md). +- [ ] If necessary, I have added documentation related to the changes made. +- [ ] I have added or updated the tests related to the changes made. \ No newline at end of file diff --git a/.github/setup/action.yml b/.github/setup/action.yml new file mode 100644 index 0000000..e4d90e6 --- /dev/null +++ b/.github/setup/action.yml @@ -0,0 +1,43 @@ +name: Setup Node + Yarn (with cache) +description: Enable Corepack, set Yarn version, restore Yarn cache, install deps +inputs: + node-version: + required: true + description: Node.js version + yarn-version: + required: true + description: Yarn Berry version + +runs: + using: "composite" + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs['node-version'] }} + + - name: Enable Corepack & set Yarn + shell: bash + run: | + corepack enable + corepack prepare yarn@${{ inputs['yarn-version'] }} --activate + + - name: Get yarn cache directory path + id: yarn-cache-dir-path + shell: bash + run: echo "dir=$(yarn config get cacheFolder)" >> "$GITHUB_OUTPUT" + + - name: Restore Yarn cache + uses: actions/cache@v4 + with: + path: | + ${{ steps.yarn-cache-dir-path.outputs.dir }} + **/node_modules + packages/*/node_modules + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + + - name: Install dependencies + shell: bash + run: yarn install --immutable diff --git a/.github/workflows/ci-coverage.yml b/.github/workflows/ci-coverage.yml new file mode 100644 index 0000000..e8fd73b --- /dev/null +++ b/.github/workflows/ci-coverage.yml @@ -0,0 +1,43 @@ +name: CI (dev with coverage) + +on: + push: + branches: [dev] + paths-ignore: + - '**.md' + +permissions: + contents: read + +env: + NODE_VERSION: 24.5.0 + YARN_VERSION: 4.9.2 + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + test-coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - uses: ./.github/setup + with: + node-version: ${{ env.NODE_VERSION }} + yarn-version: ${{ env.YARN_VERSION }} + + - name: Build shared packages + run: yarn build:shared + + - name: Unit tests with coverage + run: yarn test --coverage + + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage/** + if-no-files-found: ignore + retention-days: 7 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ac06fd..e25b18b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,6 @@ name: CI on: - push: - branches: [dev] pull_request: branches: [dev] paths-ignore: @@ -11,57 +9,36 @@ on: permissions: contents: read +env: + NODE_VERSION: 24.5.0 + YARN_VERSION: 4.9.2 + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build-and-test: runs-on: ubuntu-latest - - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - steps: - - uses: actions/checkout@v4 - - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: 24.5.0 - - - name: Enable Corepack - run: corepack enable - - - name: Set Yarn version - run: corepack prepare yarn@4.9.2 --activate - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - - uses: actions/cache@v4 - id: yarn-cache - with: - path: | - ${{ steps.yarn-cache-dir-path.outputs.dir }} - **/node_modules - packages/*/node_modules - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- + - uses: actions/checkout@v5 - - name: Install dependencies - run: yarn install --immutable + - uses: ./.github/setup + with: + node-version: ${{ env.NODE_VERSION }} + yarn-version: ${{ env.YARN_VERSION }} - - name: Check formatting - run: yarn check + - name: Check formatting + run: yarn check - - name: Build shared packages - run: yarn build:shared + - name: Build shared packages + run: yarn build:shared - - name: Unit tests with coverage - run: yarn test --coverage + - name: Unit tests with coverage + run: yarn test --coverage - - name: Build - run: yarn build + - name: Build + run: yarn build - - name: Check for security vulnerabilities - run: yarn npm audit \ No newline at end of file + - name: Check for security vulnerabilities + run: yarn npm audit diff --git a/.github/workflows/release-on-tag.yml b/.github/workflows/release-on-tag.yml new file mode 100644 index 0000000..69ce8de --- /dev/null +++ b/.github/workflows/release-on-tag.yml @@ -0,0 +1,26 @@ +name: Release on tag + +on: + push: + tags: + - "v*" + workflow_dispatch: + +permissions: + contents: write + +jobs: + create-release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + if: github.ref_type == 'tag' + with: + tag_name: ${{ github.ref_name }} + name: ${{ github.ref_name }} + generate_release_notes: true + draft: false + prerelease: ${{ contains(github.ref_name, '-rc') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-alpha') }}