5
0
Fork 0
mirror of https://github.com/wagoid/commitlint-github-action.git synced 2025-11-07 08:06:54 +00:00

Merge pull request #189 from wagoid/chore/upgrade-deps

chore: upgrade dependencies
This commit is contained in:
Wagner Santos 2021-07-15 05:35:03 -03:00 committed by GitHub
commit 711b4f40aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 17587 additions and 11528 deletions

View file

@ -1,10 +1,29 @@
{
"extends": ["airbnb-base", "prettier", "plugin:node/recommended"],
"plugins": ["prettier"],
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module"
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js"]
}
}
},
"rules": {
"prettier/prettier": "error",
"no-console": "off",
"no-process-exit": "off",
"node/no-unpublished-require": "off"
"node/no-unpublished-require": "off",
"node/no-unpublished-import": "off",
"node/no-unsupported-features/es-syntax": "off",
"import/extensions": [
"error",
{
"js": "always"
}
]
}
}

2
.husky/.gitignore vendored
View file

@ -1 +1 @@
_
_

View file

@ -1,15 +0,0 @@
const actionYamlUpdater = require.resolve('./.github/tasks/actionYamlUpdater')
module.exports = {
packageFiles: ['package.json'],
bumpFiles: [
'package.json',
'package-lock.json',
{
filename: 'action.yml',
updater: actionYamlUpdater,
},
],
releaseCommitMessageFormat:
'chore(release): publish {{currentTag}} [skip-ci]',
}

12
.versionrc.json Normal file
View file

@ -0,0 +1,12 @@
{
"packageFiles": ["package.json"],
"bumpFiles": [
"package.json",
"package-lock.json",
{
"filename": "action.yml",
"updater": "./.github/tasks/actionYamlUpdater.cjs"
}
],
"releaseCommitMessageFormat": "chore(release): publish {{currentTag}} [skip-ci]"
}

View file

@ -1,4 +1,4 @@
FROM node:12-alpine3.9
FROM node:16-alpine3.13
RUN apk --no-cache add git

View file

@ -1,5 +1,6 @@
module.exports = {
export default {
// Automatically clear mock calls and instances between every test
clearMocks: true,
testEnvironment: '@commitlint/test-environment',
transform: {},
}

28897
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -3,16 +3,17 @@
"version": "3.1.4",
"description": "commitlint github action",
"private": true,
"main": "run.js",
"exports": "./run.js",
"scripts": {
"postinstall": "husky install",
"test": "NODE_PATH=./node_modules jest",
"test": "NODE_PATH=./node_modules node --experimental-vm-modules node_modules/.bin/jest",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"lint": "eslint ."
},
"engines": {
"node": ">=12.0.0"
"node": ">=16.0.0"
},
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/wagoid/commitlint-github-action.git"
@ -23,39 +24,40 @@
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@commitlint/config-angular": "^12.0.0",
"@commitlint/config-conventional": "^12.0.0",
"@commitlint/config-lerna-scopes": "^12.0.0",
"@commitlint/config-patternplate": "^12.0.0",
"@commitlint/format": "^12.0.0",
"@commitlint/lint": "^12.0.0",
"@commitlint/load": "^12.0.0",
"commitlint-config-jira": "^1.4.1",
"commitlint-plugin-jira-rules": "^1.4.0",
"@commitlint/config-angular": "^12.1.4",
"@commitlint/config-conventional": "^12.1.4",
"@commitlint/config-lerna-scopes": "^12.1.4",
"@commitlint/config-patternplate": "^12.1.4",
"@commitlint/format": "^12.1.4",
"@commitlint/lint": "^12.1.4",
"@commitlint/load": "^12.1.4",
"commitlint-config-jira": "^1.5.1",
"commitlint-plugin-jira-rules": "^1.5.1",
"conventional-changelog-lint-config-canonical": "^1.0.0",
"dargs": "^7.0.0",
"execa": "^5.0.0",
"lerna": "^3.22.1"
"dargs": "^8.1.0",
"execa": "^5.1.1",
"lerna": "^4.0.0"
},
"devDependencies": {
"@commitlint/cli": "^12.0.0",
"@commitlint/ensure": "^12.0.0",
"@commitlint/cli": "^12.1.4",
"@commitlint/ensure": "^12.1.4",
"@commitlint/test": "^9.0.1",
"@commitlint/test-environment": "^9.0.1",
"@jest/globals": "^27.0.6",
"commitlint-plugin-function-rules": "^1.3.2",
"conventional-changelog-cli": "^2.1.1",
"eslint": "^7.23.0",
"eslint": "^7.29.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-node": "^4.1.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-prettier": "^3.4.0",
"husky": "^6.0.0",
"jest": "^26.6.3",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"standard-version": "^9.1.1",
"jest": "^27.0.6",
"lint-staged": "^11.0.0",
"prettier": "^2.3.2",
"standard-version": "^9.3.0",
"testdouble": "^3.16.1",
"yaml": "^1.10.2"
}

2
run.js
View file

@ -1,3 +1,3 @@
const action = require('./src/action')
import action from './src/action.js'
action()

View file

@ -1,12 +1,15 @@
const { existsSync } = require('fs')
const { resolve } = require('path')
const core = require('@actions/core')
const github = require('@actions/github')
const lint = require('@commitlint/lint').default
const { format } = require('@commitlint/format')
const load = require('@commitlint/load').default
const gitCommits = require('./gitCommits')
const generateOutputs = require('./generateOutputs')
import { existsSync } from 'fs'
import { resolve } from 'path'
import core from '@actions/core'
import github from '@actions/github'
import lintModule from '@commitlint/lint'
import { format } from '@commitlint/format'
import loadModule from '@commitlint/load'
import gitCommits from './gitCommits.js'
import generateOutputs from './generateOutputs.js'
const load = loadModule.default
const lint = lintModule.default
const pullRequestEvent = 'pull_request'
const pullRequestTargetEvent = 'pull_request_target'
@ -159,4 +162,4 @@ const commitLinterAction = () =>
.then(showLintResults)
.catch(exitWithMessage('error running commitlint'))
module.exports = commitLinterAction
export default commitLinterAction

View file

@ -1,16 +1,16 @@
/* eslint-disable global-require */
/* eslint-env jest */
const { git } = require('@commitlint/test')
const execa = require('execa')
const td = require('testdouble')
const {
import { jest } from '@jest/globals'
import { git } from '@commitlint/test'
import execa from 'execa'
import td from 'testdouble'
import {
gitEmptyCommit,
getCommitHashes,
updatePushEnvVars,
createPushEventPayload,
createPullRequestEventPayload,
updatePullRequestEnvVars,
} = require('./testUtils')
} from './testUtils.js'
const resultsOutputId = 'results'
@ -22,8 +22,8 @@ const initialEnv = { ...process.env }
const listCommits = td.func('listCommits')
const runAction = () => {
const github = require('@actions/github')
const runAction = async () => {
const github = (await import('@actions/github')).default
class MockOctokit {
constructor() {
this.pulls = {
@ -34,15 +34,17 @@ const runAction = () => {
td.replace(github, 'getOctokit', () => new MockOctokit())
return require('./action')()
const action = (await import('./action.js')).default
return action()
}
describe('Commit Linter action', () => {
let core
let cwd
beforeEach(() => {
core = require('@actions/core')
beforeEach(async () => {
core = (await import('@actions/core')).default
td.replace(core, 'getInput')
td.replace(core, 'setFailed')
td.replace(core, 'setOutput')
@ -147,7 +149,7 @@ describe('Commit Linter action', () => {
cwd = await git.bootstrap('fixtures/conventional')
await gitEmptyCommit(cwd, 'message from before push')
await gitEmptyCommit(cwd, 'wrong message 1')
await gitEmptyCommit(cwd, 'chore(WRONG): message 2')
await gitEmptyCommit(cwd, 'wrong message 2')
const [, , to] = await getCommitHashes(cwd)
await createPushEventPayload(cwd, { before: gitEmptySha, to })
updatePushEnvVars(cwd, to)
@ -156,7 +158,7 @@ describe('Commit Linter action', () => {
await runAction()
td.verify(core.setFailed(contains('wrong message 1')), { times: 0 })
td.verify(core.setFailed(contains('chore(WRONG): message 2')))
td.verify(core.setFailed(contains('wrong message 2')))
})
it('should fail for commit with scope that is not a lerna package', async () => {
@ -192,7 +194,7 @@ describe('Commit Linter action', () => {
it("should fail for commit that doesn't comply with jira rules", async () => {
cwd = await git.bootstrap('fixtures/jira')
td.when(core.getInput('configFile')).thenReturn('./commitlint.config.js')
td.when(core.getInput('configFile')).thenReturn('./commitlint.config.cjs')
await gitEmptyCommit(cwd, 'ib-21212121212121: without jira ticket')
const [to] = await getCommitHashes(cwd)
await createPushEventPayload(cwd, { to })
@ -551,4 +553,26 @@ describe('Commit Linter action', () => {
})
})
})
describe('when commit contains signed-off-by message', () => {
beforeEach(async () => {
cwd = await git.bootstrap('fixtures/conventional')
await gitEmptyCommit(
cwd,
'chore: correct message\n\nsome context without leading blank line\nSigned-off-by: John Doe <john.doe@example.com>',
)
const [to] = await getCommitHashes(cwd)
await createPushEventPayload(cwd, { to })
updatePushEnvVars(cwd, to)
td.replace(process, 'cwd', () => cwd)
td.replace(console, 'log')
})
it('should pass', async () => {
await runAction()
td.verify(core.setFailed(), { times: 0, ignoreExtraArgs: true })
td.verify(console.log('Lint free! 🎉'))
})
})
})

View file

@ -1,4 +1,4 @@
const core = require('@actions/core')
import core from '@actions/core'
const resultsOutputId = 'results'
@ -21,4 +21,4 @@ const generateOutputs = (lintedCommits) => {
core.setOutput(resultsOutputId, resultsOutput)
}
module.exports = generateOutputs
export default generateOutputs

View file

@ -1,5 +1,5 @@
const dargs = require('dargs')
const execa = require('execa')
import dargs from 'dargs'
import execa from 'execa'
const commitDelimiter = '--------->commit---------'
@ -40,4 +40,4 @@ const gitCommits = async (gitOpts) => {
return commits
}
module.exports = gitCommits
export default gitCommits

View file

@ -1,29 +1,27 @@
const path = require('path')
const fs = require('fs')
const { promisify } = require('util')
const execa = require('execa')
import path from 'path'
import fs from 'fs'
import { promisify } from 'util'
import execa from 'execa'
const writeFile = promisify(fs.writeFile)
const updateEnvVars = (envVars) => {
export const updateEnvVars = (envVars) => {
Object.keys(envVars).forEach((key) => {
process.env[key] = envVars[key]
})
}
exports.updateEnvVars = updateEnvVars
exports.gitEmptyCommit = (cwd, message) =>
export const gitEmptyCommit = (cwd, message) =>
execa('git', ['commit', '--allow-empty', '-m', message], { cwd })
exports.getCommitHashes = async (cwd) => {
export const getCommitHashes = async (cwd) => {
const { stdout } = await execa.command('git log --pretty=%H', { cwd })
const hashes = stdout.split('\n').reverse()
return hashes
}
exports.updatePushEnvVars = (cwd, to) => {
export const updatePushEnvVars = (cwd, to) => {
updateEnvVars({
GITHUB_WORKSPACE: cwd,
GITHUB_EVENT_NAME: 'push',
@ -31,7 +29,7 @@ exports.updatePushEnvVars = (cwd, to) => {
})
}
exports.createPushEventPayload = async (
export const createPushEventPayload = async (
cwd,
{ before = null, to, forced = false },
) => {
@ -46,7 +44,7 @@ exports.createPushEventPayload = async (
await writeFile(eventPath, JSON.stringify(payload), 'utf8')
}
exports.createPullRequestEventPayload = async (cwd) => {
export const createPullRequestEventPayload = async (cwd) => {
const payload = {
number: '1',
repository: {
@ -66,7 +64,7 @@ exports.createPullRequestEventPayload = async (cwd) => {
await writeFile(eventPath, JSON.stringify(payload), 'utf8')
}
exports.updatePullRequestEnvVars = (cwd, to, options = {}) => {
export const updatePullRequestEnvVars = (cwd, to, options = {}) => {
const { eventName = 'pull_request' } = options
updateEnvVars({