From 59e945ea474cca86af5583c9327e0375bf3f67bb Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Oct 2021 22:29:00 +0200 Subject: [PATCH 1/5] refactor: Use compiled index.js instead of node_modules --- .github/workflows/release.yml | 5 +++-- .github/workflows/test.yml | 28 ++++++++++++++++++++++++++++ .gitignore | 3 +++ README.md | 1 + action.yml | 2 +- package-lock.json | 12 +++++++++--- package.json | 10 ++++++++-- src/helpers/git.js | 18 +++++++++++++----- src/index.js | 2 +- 9 files changed, 67 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a63c8f5..8523093 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,8 +11,9 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - run: npm ci --prod - - run: git add node_modules -f + - run: npm ci + - run: npm run build + - run: git add ./lib -f - name: Generate changelog id: changelog diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 474fe79..4dfbca3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -135,6 +135,34 @@ jobs: github-token: ${{ secrets.github_token }} skip-commit: 'true' + test-git-no-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + path: "./" + + - run: npm ci --prod + - run: "git config --global user.email 'changelog@github.com'" + - run: "git config --global user.name 'Awesome Github action'" + + - run: git tag | xargs git tag -d + - name: Create fake tag + run: "git tag -a 'v0.55.8' -m 'v0.55.8'" + - run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" + + - name: Generate changelog + id: changelog + uses: ./ + env: + ENV: 'dont-use-git' + EXPECTED_TAG: 'v0.55.9' + SKIPPED_COMMIT: true + with: + github-token: ${{ secrets.github_token }} + git-push: 'false' + test-git-fallback: runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index 80338dc..acefc27 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,6 @@ typings/ # next.js build output .next + +# build output +lib diff --git a/README.md b/README.md index 72ea55c..edca823 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ This action will bump version, tag commit and generate a changelog with conventi - **Optional** `git-user-name`: The git user.name to use for the commit. Default `Conventional Changelog Action` - **Optional** `git-user-email`: The git user.email to use for the commit. Default `conventional.changelog.action@github.com` - **Optional** `git-pull-method`: The git pull method used when pulling all changes from remote. Default `--ff-only` +- **Optional** `git-push`: Push all the GIT changes. Default `true` - **Optional** `preset`: Preset that is used from conventional commits. Default `angular`. - **Optional** `tag-prefix`: Prefix for the git tags. Default `v`. - **Optional** `output-file`: File to output the changelog to. Default `CHANGELOG.md`, when providing `'false'` no file will be generated / updated. diff --git a/action.yml b/action.yml index e311ad8..790c497 100644 --- a/action.yml +++ b/action.yml @@ -3,7 +3,7 @@ description: 'Bump version, tag commit and generates changelog with conventional author: 'Tycho Bokdam' runs: using: 'node12' - main: 'src/index.js' + main: 'lib/index.js' branding: icon: 'edit' diff --git a/package-lock.json b/package-lock.json index 9830cf5..39c3e4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -454,6 +454,12 @@ "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==", "dev": true }, + "@vercel/ncc": { + "version": "0.31.1", + "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.31.1.tgz", + "integrity": "sha512-g0FAxwdViI6UzsiVz5HssIHqjcPa1EHL6h+2dcJD893SoCJaGdqqgUF09xnMW6goWnnhbLvgiKlgJWrJa+7qYA==", + "dev": true + }, "JSONStream": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", @@ -1182,9 +1188,9 @@ } }, "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, "requires": { "ansi-styles": "^4.1.0", diff --git a/package.json b/package.json index 9ba088e..52e4cf7 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "changelog", "commits", "conventional", - "github" + "github", + "conventional commits" ], "homepage": "https://github.com/TriPSs/conventional-changelog-action#readme", "bugs": { @@ -22,7 +23,11 @@ "name": "Tycho Bokdam", "email": "tycho@palmtreecoding.com" }, - "main": "src/index.js", + "main": "lib/index.js", + "scripts": { + "build": "ncc build src/index.js --minify --out lib", + "watch": "ncc build src/index.js --watch" + }, "dependencies": { "@actions/core": "1.6.0", "@actions/exec": "1.1.0", @@ -37,6 +42,7 @@ "devDependencies": { "@commitlint/cli": "13.2.0", "@commitlint/config-conventional": "13.2.0", + "@vercel/ncc": "^0.31.1", "husky": "4.3.6" } } diff --git a/src/helpers/git.js b/src/helpers/git.js index 74bb6c2..ab8a8e6 100644 --- a/src/helpers/git.js +++ b/src/helpers/git.js @@ -48,7 +48,7 @@ module.exports = new (class Git { * @param command * @return {Promise<>} */ - exec = (command) => new Promise(async(resolve, reject) => { + exec = (command) => new Promise(async (resolve, reject) => { let execOutput = '' const options = { @@ -102,7 +102,7 @@ module.exports = new (class Git { * * @return {Promise<>} */ - pull = async() => { + pull = async () => { const args = ['pull'] // Check if the repo is unshallow @@ -130,7 +130,7 @@ module.exports = new (class Git { * * @return {Promise<>} */ - isShallow = async() => { + isShallow = async () => { if (ENV === 'dont-use-git') { return false } @@ -159,7 +159,7 @@ module.exports = new (class Git { /** * Validates the commands run */ - testHistory = () => { + testHistory = (gitPush) => { if (ENV === 'dont-use-git') { const { EXPECTED_TAG, SKIPPED_COMMIT } = process.env @@ -175,7 +175,15 @@ module.exports = new (class Git { } expectedCommands.push(`git tag -a ${EXPECTED_TAG} -m "${EXPECTED_TAG}"`) - expectedCommands.push(`git push origin ${branch} --follow-tags`) + + if (gitPush) { + expectedCommands.push(`git push origin ${branch} --follow-tags`) + } + + console.log('Testing GIT history') + console.log(this.commandsRun) + console.log('Should equal') + console.log(expectedCommands) assert.deepStrictEqual( this.commandsRun, diff --git a/src/index.js b/src/index.js index f36e63d..9061566 100644 --- a/src/index.js +++ b/src/index.js @@ -199,7 +199,7 @@ async function run() { try { // If we are running in test mode we use this to validate everything still runs - git.testHistory() + git.testHistory(gitPush) } catch (error) { console.error(error) From 98bfe0d97818928b2b4656c490281971f3f8fe47 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Oct 2021 22:32:03 +0200 Subject: [PATCH 2/5] ci: Updated test scripts --- .github/workflows/test.yml | 48 +++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4dfbca3..7832025 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -47,7 +48,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -81,7 +83,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -115,7 +118,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -143,7 +147,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -171,7 +176,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -198,7 +204,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -268,7 +275,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -306,7 +314,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -342,7 +351,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -378,7 +388,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -414,7 +425,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -453,7 +465,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -485,7 +498,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -519,7 +533,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -560,7 +575,8 @@ jobs: with: path: "./" - - run: npm ci --prod + - run: npm ci + - run: npm build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" From 9c993a479649f96231c1aaf44e62d555801fddb2 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Oct 2021 22:33:11 +0200 Subject: [PATCH 3/5] ci: Updated test scripts --- .github/workflows/test.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7832025..ee9050c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,7 +14,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -49,7 +49,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -84,7 +84,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -119,7 +119,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -148,7 +148,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -177,7 +177,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -205,7 +205,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -276,7 +276,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -315,7 +315,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -352,7 +352,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -389,7 +389,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -426,7 +426,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -466,7 +466,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -499,7 +499,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -534,7 +534,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -576,7 +576,7 @@ jobs: path: "./" - run: npm ci - - run: npm build + - run: npm run build - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" From 0fc388f4a3ff766339e453023a13a0c6532c3a22 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Oct 2021 22:35:09 +0200 Subject: [PATCH 4/5] ci: Fixed git-no-push test script --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ee9050c..492e5e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -163,7 +163,6 @@ jobs: env: ENV: 'dont-use-git' EXPECTED_TAG: 'v0.55.9' - SKIPPED_COMMIT: true with: github-token: ${{ secrets.github_token }} git-push: 'false' From 9f9635115ed24cd13d269bc14e543943cc784787 Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Tue, 5 Oct 2021 22:56:24 +0200 Subject: [PATCH 5/5] ci: Improve test scripts --- .github/workflows/test.yml | 107 +++++++++++++++++++++++++++---------- src/helpers/git.js | 11 ++-- src/index.js | 2 +- 3 files changed, 83 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 492e5e6..6988aaf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,6 +15,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -50,6 +53,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -85,6 +91,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -120,6 +129,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -139,34 +151,6 @@ jobs: github-token: ${{ secrets.github_token }} skip-commit: 'true' - test-git-no-push: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 - with: - path: "./" - - - run: npm ci - - run: npm run build - - run: "git config --global user.email 'changelog@github.com'" - - run: "git config --global user.name 'Awesome Github action'" - - - run: git tag | xargs git tag -d - - name: Create fake tag - run: "git tag -a 'v0.55.8' -m 'v0.55.8'" - - run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" - - - name: Generate changelog - id: changelog - uses: ./ - env: - ENV: 'dont-use-git' - EXPECTED_TAG: 'v0.55.9' - with: - github-token: ${{ secrets.github_token }} - git-push: 'false' - test-git-fallback: runs-on: ubuntu-latest steps: @@ -177,6 +161,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -195,6 +182,40 @@ jobs: github-token: ${{ secrets.github_token }} skip-commit: 'true' + test-git-no-push: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + path: "./" + + - run: npm ci + - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + + - run: "git config --global user.email 'changelog@github.com'" + - run: "git config --global user.name 'Awesome Github action'" + + - run: git tag | xargs git tag -d + - name: Create fake tag + run: "git tag -a 'v0.55.8' -m 'v0.55.8'" + - run: "git add . && git commit -m 'fix: Added fake file so version will be bumped'" + + - name: Generate changelog + id: changelog + uses: ./ + env: + ENV: 'dont-use-git' + EXPECTED_TAG: 'v0.55.9' + SKIPPED_COMMIT: true + EXPECTED_NO_PUSH: true + with: + github-token: ${{ secrets.github_token }} + skip-commit: 'true' + git-push: 'false' + test-yaml: runs-on: ubuntu-latest steps: @@ -205,6 +226,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -276,6 +300,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -315,6 +342,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -352,6 +382,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -389,6 +422,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -426,6 +462,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -466,6 +505,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -499,6 +541,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -534,6 +579,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" @@ -576,6 +624,9 @@ jobs: - run: npm ci - run: npm run build + - run: rm -rf node_modules + - run: npm ci --prod + - run: touch ./fake-file.log - run: "git config --global user.email 'changelog@github.com'" - run: "git config --global user.name 'Awesome Github action'" diff --git a/src/helpers/git.js b/src/helpers/git.js index ab8a8e6..f77058f 100644 --- a/src/helpers/git.js +++ b/src/helpers/git.js @@ -159,9 +159,9 @@ module.exports = new (class Git { /** * Validates the commands run */ - testHistory = (gitPush) => { + testHistory = () => { if (ENV === 'dont-use-git') { - const { EXPECTED_TAG, SKIPPED_COMMIT } = process.env + const { EXPECTED_TAG, SKIPPED_COMMIT, EXPECTED_NO_PUSH } = process.env const expectedCommands = [ 'git config user.name "Conventional Changelog Action"', @@ -176,15 +176,10 @@ module.exports = new (class Git { expectedCommands.push(`git tag -a ${EXPECTED_TAG} -m "${EXPECTED_TAG}"`) - if (gitPush) { + if (!EXPECTED_NO_PUSH) { expectedCommands.push(`git push origin ${branch} --follow-tags`) } - console.log('Testing GIT history') - console.log(this.commandsRun) - console.log('Should equal') - console.log(expectedCommands) - assert.deepStrictEqual( this.commandsRun, expectedCommands, diff --git a/src/index.js b/src/index.js index 9061566..f36e63d 100644 --- a/src/index.js +++ b/src/index.js @@ -199,7 +199,7 @@ async function run() { try { // If we are running in test mode we use this to validate everything still runs - git.testHistory(gitPush) + git.testHistory() } catch (error) { console.error(error)