From a1a02f4986a1eba0052f26bd916bf1a27a9c6660 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Thu, 31 Oct 2019 09:02:09 +0000 Subject: [PATCH 1/4] feat(ssf): remove TOFS overrides for updating `ssf/defaults.yaml` * Unused, so unnecessary duplication when fixes are required --- .../pre-commit_semantic-release.sh | 37 ------ ssf/files/tofs_ssf-formula/release.config.js | 106 ------------------ 2 files changed, 143 deletions(-) delete mode 100755 ssf/files/tofs_ssf-formula/pre-commit_semantic-release.sh delete mode 100644 ssf/files/tofs_ssf-formula/release.config.js diff --git a/ssf/files/tofs_ssf-formula/pre-commit_semantic-release.sh b/ssf/files/tofs_ssf-formula/pre-commit_semantic-release.sh deleted file mode 100755 index d900f3a0..00000000 --- a/ssf/files/tofs_ssf-formula/pre-commit_semantic-release.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -############################################################################### -# (A) Update `FORMULA` with `${nextRelease.version}` -############################################################################### -sed -i -e "s_^\(version:\).*_\1 ${1}_" FORMULA - - -############################################################################### -# (B) Use `m2r` to convert automatically produced `.md` docs to `.rst` -############################################################################### - -# Install `m2r` -sudo -H pip install m2r - -# Copy and then convert the `.md` docs -cp *.md docs/ -cd docs/ -m2r --overwrite *.md - -# Change excess `H1` headings to `H2` in converted `CHANGELOG.rst` -sed -i -e '/^=.*$/s/=/-/g' CHANGELOG.rst -sed -i -e '1,4s/-/=/g' CHANGELOG.rst - -# Use for debugging output, when required -# cat AUTHORS.rst -# cat CHANGELOG.rst - -# Return back to the main directory -cd .. - - -############################################################################### -# (C) Update `ssf/defaults.yaml` with `${nextRelease.version}` -############################################################################### -V_REPR=v${1} -sed -i -e "s_^\(\s\+body: '\* Automated using \`ssf-formula\` (\).*\()'\)_\1${V_REPR}\2_" ssf/defaults.yaml diff --git a/ssf/files/tofs_ssf-formula/release.config.js b/ssf/files/tofs_ssf-formula/release.config.js deleted file mode 100644 index 0ade10e8..00000000 --- a/ssf/files/tofs_ssf-formula/release.config.js +++ /dev/null @@ -1,106 +0,0 @@ -module.exports = { - branch: 'master', - plugins: [ - ['@semantic-release/commit-analyzer', { - preset: 'angular', - releaseRules: './release-rules.js', - }], - '@semantic-release/release-notes-generator', - ['@semantic-release/changelog', { - changelogFile: 'CHANGELOG.md', - changelogTitle: '# Changelog', - }], - ['@semantic-release/exec', { - prepareCmd: 'sh ./pre-commit_semantic-release.sh ${nextRelease.version}', - }], - ['@semantic-release/git', { - assets: ['*.md', 'docs/*.rst', 'FORMULA', 'ssf/defaults.yaml'], - }], - '@semantic-release/github', - ], - generateNotes: { - preset: 'angular', - writerOpts: { - // Required due to upstream bug preventing all types being displayed. - // Bug: https://github.com/conventional-changelog/conventional-changelog/issues/317 - // Fix: https://github.com/conventional-changelog/conventional-changelog/pull/410 - transform: (commit, context) => { - const issues = [] - - commit.notes.forEach(note => { - note.title = `BREAKING CHANGES` - }) - - // NOTE: Any changes here must be reflected in `CONTRIBUTING.md`. - if (commit.type === `feat`) { - commit.type = `Features` - } else if (commit.type === `fix`) { - commit.type = `Bug Fixes` - } else if (commit.type === `perf`) { - commit.type = `Performance Improvements` - } else if (commit.type === `revert`) { - commit.type = `Reverts` - } else if (commit.type === `docs`) { - commit.type = `Documentation` - } else if (commit.type === `style`) { - commit.type = `Styles` - } else if (commit.type === `refactor`) { - commit.type = `Code Refactoring` - } else if (commit.type === `test`) { - commit.type = `Tests` - } else if (commit.type === `build`) { - commit.type = `Build System` - // } else if (commit.type === `chore`) { - // commit.type = `Maintenance` - } else if (commit.type === `ci`) { - commit.type = `Continuous Integration` - } else { - return - } - - if (commit.scope === `*`) { - commit.scope = `` - } - - if (typeof commit.hash === `string`) { - commit.hash = commit.hash.substring(0, 7) - } - - if (typeof commit.subject === `string`) { - let url = context.repository - ? `${context.host}/${context.owner}/${context.repository}` - : context.repoUrl - if (url) { - url = `${url}/issues/` - // Issue URLs. - commit.subject = commit.subject.replace(/#([0-9]+)/g, (_, issue) => { - issues.push(issue) - return `[#${issue}](${url}${issue})` - }) - } - if (context.host) { - // User URLs. - commit.subject = commit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => { - if (username.includes('/')) { - return `@${username}` - } - - return `[@${username}](${context.host}/${username})` - }) - } - } - - // remove references that already appear in the subject - commit.references = commit.references.filter(reference => { - if (issues.indexOf(reference.issue) === -1) { - return true - } - - return false - }) - - return commit - }, - }, - }, -}; From 478ff379794cd45921fbc24b83e1bd9d65dcb49d Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Thu, 31 Oct 2019 09:05:23 +0000 Subject: [PATCH 2/4] feat(release.config.js): use full commit hash in commit link * https://github.com/conventional-changelog/conventional-changelog/pull/523 - Get latest changes introduced by this PR - Fixes commit short hashes no longer showing in both the release notes and the changelog --- ssf/files/default/release.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssf/files/default/release.config.js b/ssf/files/default/release.config.js index afa0cb11..6af7aa8f 100644 --- a/ssf/files/default/release.config.js +++ b/ssf/files/default/release.config.js @@ -63,7 +63,7 @@ module.exports = { } if (typeof commit.hash === `string`) { - commit.hash = commit.hash.substring(0, 7) + commit.shortHash = commit.hash.substring(0, 7) } if (typeof commit.subject === `string`) { From 56c4b8445ce16c87af90334e04a66a54a6710161 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Thu, 31 Oct 2019 09:54:10 +0000 Subject: [PATCH 3/4] feat(travis): merge `npm install` commands and use shortened form --- ssf/files/default/.travis.yml | 10 +++++----- ssf/files/tofs_ssf-formula/.travis.yml | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ssf/files/default/.travis.yml b/ssf/files/default/.travis.yml index f5d11100..eaeb26df 100644 --- a/ssf/files/default/.travis.yml +++ b/ssf/files/default/.travis.yml @@ -132,8 +132,8 @@ jobs: {{- format_rubocop_linter() }} {%- endif %} # Install and run `commitlint` - - npm install @commitlint/config-conventional -D - - npm install @commitlint/travis-cli -D + - npm i -D @commitlint/config-conventional + @commitlint/travis-cli - commitlint-travis {%- if not travis.use_single_job_for_linters %} # Run the `rubocop` linter in a separate job that is allowed to fail @@ -188,9 +188,9 @@ jobs: - maintainer contributor # Install all dependencies required for `semantic-release` - - npm install @semantic-release/changelog@3 -D - - npm install @semantic-release/exec@3 -D - - npm install @semantic-release/git@7 -D + - npm i -D @semantic-release/changelog@3 + @semantic-release/exec@3 + @semantic-release/git@7 deploy: provider: script skip_cleanup: true diff --git a/ssf/files/tofs_ssf-formula/.travis.yml b/ssf/files/tofs_ssf-formula/.travis.yml index 60dc1d09..e4354b5d 100644 --- a/ssf/files/tofs_ssf-formula/.travis.yml +++ b/ssf/files/tofs_ssf-formula/.travis.yml @@ -137,8 +137,8 @@ jobs: {{- format_rubocop_linter() }} {%- endif %} # Install and run `commitlint` - - npm install @commitlint/config-conventional -D - - npm install @commitlint/travis-cli -D + - npm i -D @commitlint/config-conventional + @commitlint/travis-cli - commitlint-travis {%- if not travis.use_single_job_for_linters %} # Run the `rubocop` linter in a separate job that is allowed to fail @@ -193,9 +193,9 @@ jobs: - maintainer contributor # Install all dependencies required for `semantic-release` - - npm install @semantic-release/changelog@3 -D - - npm install @semantic-release/exec@3 -D - - npm install @semantic-release/git@7 -D + - npm i -D @semantic-release/changelog@3 + @semantic-release/exec@3 + @semantic-release/git@7 deploy: provider: 'script' skip_cleanup: true From 6313556fcb637d3d60f5ddf0d35816efbe71f4f3 Mon Sep 17 00:00:00 2001 From: Imran Iqbal Date: Thu, 31 Oct 2019 10:08:46 +0000 Subject: [PATCH 4/4] chore(defaults): prepare commit title and body to be used in formulas --- ssf/defaults.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ssf/defaults.yaml b/ssf/defaults.yaml index 57faad04..11ef2391 100644 --- a/ssf/defaults.yaml +++ b/ssf/defaults.yaml @@ -22,8 +22,8 @@ ssf_node_anchors: # An alternative method could be to use: # `git describe --abbrev=0 --tags` # yamllint disable rule:line-length - title: 'feat(semantic-release): implement for this formula' - body: '* Checked using https://github.com/myii/ssf-formula/pull/88' + title: 'fix(release.config.js): use full commit hash in commit link [skip ci]' + body: '* Automated using https://github.com/myii/ssf-formula/pull/89' # yamllint enable rule:line-length github: owner: 'saltstack-formulas'