Skip to content

Commit

Permalink
fix: build the action with rollup
Browse files Browse the repository at this point in the history
On v4, we used the default nodejs resolution logic to allow ES modules in dependencies.
This created a breaking change of forcing users of this action
to use the .cjs extension instead of .js in config files.

With this fix, we now bundle the action with rollup to allow ES modules
in dependencies, while keeping the support for .js config files.

With this change, the default config file was returned back to .js instead of
.cjs.

Fixes #194
  • Loading branch information
wagoid committed Jul 17, 2021
1 parent 0cb522a commit 2e57812
Show file tree
Hide file tree
Showing 23 changed files with 16,051 additions and 220 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
node_modules
commitlint.config.cjs
commitlint.config.js
action.yml
.github
CHANGELOG.md
Expand Down
8 changes: 1 addition & 7 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
"no-process-exit": "off",
"node/no-unpublished-require": "off",
"node/no-unpublished-import": "off",
"node/no-unsupported-features/es-syntax": "off",
"import/extensions": [
"error",
{
"js": "always"
}
]
"node/no-unsupported-features/es-syntax": "off"
}
}
File renamed without changes.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ typings/

# next.js build output
.next

# Dist files
dist
File renamed without changes.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
16.5.0
2 changes: 1 addition & 1 deletion .versionrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"package-lock.json",
{
"filename": "action.yml",
"updater": "./.github/tasks/actionYamlUpdater.cjs"
"updater": "./.github/tasks/actionYamlUpdater.js"
}
],
"releaseCommitMessageFormat": "chore(release): publish {{currentTag}} [skip-ci]"
Expand Down
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ All notable changes to this project will be documented in this file. See [standa

* Node.js version used on the action updated from 12 to
16
* Config files now need to be renamed from .js to .cjs

### Features

Expand Down
16 changes: 14 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
FROM node:16-alpine3.13
FROM node:16.5.0-alpine3.14 as build

COPY package*.json /

RUN npm ci --ignore-scripts

COPY . .

RUN npm run build

FROM node:16.5.0-alpine3.14

RUN apk --no-cache add git

COPY --from=build dist/run.js /run.js

COPY package*.json /

RUN npm ci --production --ignore-scripts

COPY . .
COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ You can supply these inputs to the `wagoid/commitlint-github-action@v3` step.

The path to your commitlint config file.

Default: `commitlint.config.cjs`
Default: `commitlint.config.js`

If the config file doesn't exist, [config-conventional](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional) settings will be loaded as a default fallback.

Expand Down
9 changes: 5 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ description: Lints Pull Request commit messages with commitlint
author: Wagner Santos
inputs:
configFile:
description: Commitlint config file. If the file doesn't exist, config-conventional settings will be
description:
Commitlint config file. If the file doesn't exist, config-conventional settings will be
loaded as a fallback.
default: ./commitlint.config.cjs
default: ./commitlint.config.js
required: false
firstParent:
description: >
When set to true, we follow only the first parent commit when seeing a merge commit. More info
in git-log docs https://git-scm.com/docs/git-log#Documentation/git-log.txt---first-parent
default: "true"
default: 'true'
required: false
failOnWarnings:
description: Whether you want to fail on warnings or not
default: "false"
default: 'false'
required: false
helpURL:
description: Link to a page explaining your commit message convention
Expand Down
6 changes: 6 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [["@babel/preset-env"]],
"targets": {
"node": "16.5.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 6 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export default {
module.exports = {
// Automatically clear mock calls and instances between every test
// preset: 'rollup-jest',
clearMocks: true,
testEnvironment: '@commitlint/test-environment',
transform: {},
transform: {
'\\.[jt]sx?$': 'babel-jest',
},
transformIgnorePatterns: ['node_modules/(?!dargs)'],
}
Loading

0 comments on commit 2e57812

Please sign in to comment.