Skip to content

Commit

Permalink
Merge pull request #479 from buildkite-plugins/SUP-1263_TagVersioning…
Browse files Browse the repository at this point in the history
…_Update

Sup 1263 - Tag versioning update
  • Loading branch information
pzeballos authored Jul 19, 2023
2 parents 65f6176 + 6540d9f commit 948d40e
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/linters/example-linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ module.exports = async function (argv, tap) {
refMatches = pluginRef.pathname === `/${id}`
}

return refMatches && hash && hash.startsWith('#v')
return refMatches && hash && hash.startsWith('#')
}

function extractPluginConfigs (exampleYaml) {
Expand Down
2 changes: 1 addition & 1 deletion lib/linters/readme-version-number-linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { compareVersions, validate } = require('compare-versions')
module.exports = async function (argv, tap) {
const { id, path: pluginPath, readme, silent } = argv

const pluginConfigKeyPattern = new RegExp(`${id}#(v.*):`, 'g')
const pluginConfigKeyPattern = new RegExp(`${id}#(v?.*):`, 'g')

const readmePath = path.join(pluginPath, readme)
const readmeContents = fs.readFileSync(readmePath, 'utf8')
Expand Down
8 changes: 8 additions & 0 deletions test/example-linter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ describe('example-linter', () => {
readme: 'README.md'
}, tap))
})
it('should be valid without v', async () => {
assert(await linter({
id: 'valid-plugin',
path: path.join(fixtures, 'valid-plugin'),
silent: true,
readme: 'README-with-anything.md'
}, tap))
})
})
describe('valid plugin with yaml instead of yml', () => {
it('should be valid', async () => {
Expand Down
8 changes: 8 additions & 0 deletions test/example-linter/valid-plugin/README-with-anything.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Example

```yml
steps:
- plugins:
- valid-plugin#p1.2.3:
option: value
```
10 changes: 10 additions & 0 deletions test/readme-version-number-linter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ describe('readme-version-number-linter', () => {
}, tap))
})
})
describe('readme with out of date version numbers and no v prefix', () => {
it('should be invalid', async () => {
assert.isFalse(await linter({
id: 'out-of-date',
path: initGitFixture(path.join(fixtures, 'out-of-date')),
readme: 'README-No-Version.md',
silent: true
}, tap))
})
})
describe('readme withan invalid version number', () => {
it('should ignore the invalid', async () => {
assert(await linter({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
steps:
- plugins:
- custom-readme#v1.0.0: ~
- custom-readme#1.0.0: ~
1 change: 1 addition & 0 deletions test/readme-version-number-linter/future-version/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
steps:
- plugins:
- future-version#v2.0.0: ~
- future-version#2.0.0: ~
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
steps:
- plugins:
- invalid-sem-ver-tags#v0.2.0: ~
- invalid-sem-ver-tags#v0.2.0: ~
- invalid-sem-ver-tags#0.2.0: ~
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
steps:
- plugins:
- out-of-date#0.0.1: ~
1 change: 1 addition & 0 deletions test/readme-version-number-linter/up-to-date/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
steps:
- plugins:
- up-to-date#v1.0.0: ~
- up-to-date#1.0.0: ~

0 comments on commit 948d40e

Please sign in to comment.