From ef741acb20a46b2fcd7253ad4af882b90b80b3fb Mon Sep 17 00:00:00 2001 From: ryanformio Date: Mon, 24 Jun 2024 21:57:39 -0500 Subject: [PATCH 1/6] Adds PR template and ci.yml --- .github/pull_request_template.md | 35 +++++++++ .github/workflows/ci.yml | 128 +++++++++++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/ci.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..bfe6e4445 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,35 @@ +## Link to Jira Ticket + +https://formio.atlassian.net/browse/FIO-XXXX + +## Description + +**What changed?** + +*Use this section to provide a summary description of the changes you've made* + +**Why have you chosen this solution?** + +*Use this section to justify your choices* + +## Breaking Changes / Backwards Compatibility + +*Use this section to describe any potentially breaking changes this PR introduces or any effects this PR might have on backwards compatibility* + +## Dependencies + +*Use this section to list any dependent changes/PRs in other Form.io modules* + +## How has this PR been tested? + +*Use this section to describe how you tested your changes; if you haven't included automated tests, justify your reasoning* + +## Checklist: + +- [ ] I have completed the above PR template +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation (if applicable) +- [ ] My changes generate no new warnings +- [ ] My changes include tests that prove my fix is effective (or that my feature works as intended) +- [ ] New and existing unit/integration tests pass locally with my changes +- [ ] Any dependent changes have corresponding PRs that are listed above \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..0a7092e68 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,128 @@ +name: Build, Test, Publish + +on: + pull_request: + types: [opened, synchronize] + +env: + NODE_VERSION: 20.x + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out repository code ${{ github.repository }} on ${{ github.ref }} + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git user + run: | + git config --global user.email "pkgbot@form.io" + git config --global user.name "pkgbot" + + - name: Merge target branch into current branch + run: | + git fetch origin ${{ github.event.pull_request.base.ref }}:${{ github.event.pull_request.base.ref }} + git merge ${{ github.event.pull_request.base.ref }} --no-commit --no-ff + + - name: Check for merge conflicts + run: | + if ! git merge --no-commit --no-ff ${{ github.event.pull_request.base.ref }}; then + echo "Merge conflicts detected." + git merge --abort + exit 1 + else + echo "Merge successful." + fi + + - name: Set up Node.js ${{ env.NODE_VERSION }} + uses: actions/setup-node@v3 + with: + node-version: ${{ env.NODE_VERSION }} + cache: "npm" + + - name: Install dependencies (This triggers a build step) + run: yarn install --frozen-lockfile + + - name: Cache node modules + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- + + #################################### + ## Currently no test folder + #################################### + # - name: Test + # uses: borales/actions-yarn@v4 + # with: + # cmd: test + + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: build-artifact + path: | + dist/ + lib/ + LICENSE.txt + README.md + package.json + + publish: + needs: build + if: github.event.pull_request.base.ref == 'master' + runs-on: ubuntu-latest + steps: + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: build-artifact + path: ./ + + - name: View downloaded build output + run: ls -a + + # - name: Restore node modules from cache + # uses: actions/cache@v3 + # with: + # path: node_modules + # key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + # restore-keys: | + # ${{ runner.os }}-node- + + # - name: Add npm token to .npmrc + # run: | + # echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc + + # - name: Prepare version for publish + # id: prep + # run: | + # # Extract the pull request number and the short SHA of the commit + # PR_NUMBER=$(echo ${{ github.event.number }}) + # COMMIT_SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7) + + # # Extract the current version from package.json + # CURRENT_VERSION=$(node -p "require('./package.json').version") + + # # If the current version includes '-rc.', remove it and everything after + # # This step ensures that we start with a base version like '3.0.0' even if it was a release candidate + # BASE_VERSION=$(echo "$CURRENT_VERSION" | cut -d'-' -f1) + + # # Construct the new version string + # NEW_VERSION="${BASE_VERSION}-dev.${PR_NUMBER}.${COMMIT_SHORT_SHA}" + + # # Output the new version for use in subsequent GitHub Actions steps + # echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + + # - name: Echo version to publish + # run: | + # echo "Version to publish: $NEW_VERSION" + + # - name: Publish to npm + # run: | + # npm version $NEW_VERSION + # yarn publish --ignore-scripts --tag dev \ No newline at end of file From 0235b4f9df828e2262b25ae5be09f83a783a8c60 Mon Sep 17 00:00:00 2001 From: ryanformio Date: Mon, 24 Jun 2024 22:01:50 -0500 Subject: [PATCH 2/6] Forgot build step --- .github/workflows/ci.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a7092e68..7d1eb1073 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,13 +53,10 @@ jobs: restore-keys: | ${{ runner.os }}-node- - #################################### - ## Currently no test folder - #################################### - # - name: Test - # uses: borales/actions-yarn@v4 - # with: - # cmd: test + - name: Build + uses: borales/actions-yarn@v4 + with: + cmd: build - name: Upload build artifact uses: actions/upload-artifact@v3 From 732e6df8d36319f2ce08fa305881c69a00bb1f4f Mon Sep 17 00:00:00 2001 From: ryanformio Date: Mon, 24 Jun 2024 22:03:56 -0500 Subject: [PATCH 3/6] Remove hint, not needed for this repo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7d1eb1073..b345fd5e1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: node-version: ${{ env.NODE_VERSION }} cache: "npm" - - name: Install dependencies (This triggers a build step) + - name: Install dependencies run: yarn install --frozen-lockfile - name: Cache node modules From 0554fd74d1562a03e240bca9307a6fa672b27dcc Mon Sep 17 00:00:00 2001 From: ryanformio Date: Mon, 24 Jun 2024 22:04:43 -0500 Subject: [PATCH 4/6] Remove hint, not needed for this repo --- .github/workflows/ci.yml | 60 ++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b345fd5e1..3f7427362 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -83,43 +83,43 @@ jobs: - name: View downloaded build output run: ls -a - # - name: Restore node modules from cache - # uses: actions/cache@v3 - # with: - # path: node_modules - # key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} - # restore-keys: | - # ${{ runner.os }}-node- - - # - name: Add npm token to .npmrc - # run: | - # echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc + - name: Restore node modules from cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-node- - # - name: Prepare version for publish - # id: prep - # run: | - # # Extract the pull request number and the short SHA of the commit - # PR_NUMBER=$(echo ${{ github.event.number }}) - # COMMIT_SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7) + - name: Add npm token to .npmrc + run: | + echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc + + - name: Prepare version for publish + id: prep + run: | + # Extract the pull request number and the short SHA of the commit + PR_NUMBER=$(echo ${{ github.event.number }}) + COMMIT_SHORT_SHA=$(echo "${{ github.event.pull_request.head.sha }}" | cut -c1-7) - # # Extract the current version from package.json - # CURRENT_VERSION=$(node -p "require('./package.json').version") + # Extract the current version from package.json + CURRENT_VERSION=$(node -p "require('./package.json').version") - # # If the current version includes '-rc.', remove it and everything after - # # This step ensures that we start with a base version like '3.0.0' even if it was a release candidate - # BASE_VERSION=$(echo "$CURRENT_VERSION" | cut -d'-' -f1) + # If the current version includes '-rc.', remove it and everything after + # This step ensures that we start with a base version like '3.0.0' even if it was a release candidate + BASE_VERSION=$(echo "$CURRENT_VERSION" | cut -d'-' -f1) - # # Construct the new version string - # NEW_VERSION="${BASE_VERSION}-dev.${PR_NUMBER}.${COMMIT_SHORT_SHA}" + # Construct the new version string + NEW_VERSION="${BASE_VERSION}-dev.${PR_NUMBER}.${COMMIT_SHORT_SHA}" - # # Output the new version for use in subsequent GitHub Actions steps - # echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV + # Output the new version for use in subsequent GitHub Actions steps + echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV - # - name: Echo version to publish - # run: | - # echo "Version to publish: $NEW_VERSION" + - name: Echo version to publish + run: | + echo "Version to publish: $NEW_VERSION" # - name: Publish to npm # run: | # npm version $NEW_VERSION - # yarn publish --ignore-scripts --tag dev \ No newline at end of file + # yarn publish --tag dev \ No newline at end of file From 8a2e9241c217cb06a350b6a53cb9d300fd13ec65 Mon Sep 17 00:00:00 2001 From: ryanformio Date: Mon, 24 Jun 2024 22:15:28 -0500 Subject: [PATCH 5/6] test publish --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3f7427362..7c6e1e1cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,7 +119,7 @@ jobs: run: | echo "Version to publish: $NEW_VERSION" - # - name: Publish to npm - # run: | - # npm version $NEW_VERSION - # yarn publish --tag dev \ No newline at end of file + - name: Publish to npm + run: | + npm version $NEW_VERSION + yarn publish --tag dev \ No newline at end of file From 8405cde4b0b2a006a566cbdae70e9269d958a356 Mon Sep 17 00:00:00 2001 From: ryanformio Date: Mon, 24 Jun 2024 22:27:01 -0500 Subject: [PATCH 6/6] Rename the CI, since no test --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c6e1e1cf..71abcbab9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Build, Test, Publish +name: Build, Publish on: pull_request: