refactor(buildkite): remove fixtures (#31134)

This commit is contained in:
Jamie Tanna 2024-08-31 10:31:38 +01:00 committed by GitHub
parent fad5e98c71
commit aff5d94b4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 96 additions and 86 deletions

View file

@ -1,3 +0,0 @@
steps:
- plugins:
abc/detect-clowns#v2.0.0: ~

View file

@ -1,17 +0,0 @@
steps:
# Prebuild the app image, upload it to a registry for later steps
- name: "Docker Build"
plugins:
docker-compose#v1.3.2: # Comment at the end....
build: app
image-repository: index.docker.io/org/repo
- wait
# Use the app image built above to run concurrent tests
- name: "Docker Test %n"
command: test.sh
parallelism: 25
plugins:
docker-compose#v1.3.2:
run: app

View file

@ -1,16 +0,0 @@
steps:
# Prebuild the app image, upload it to a registry for later steps
- name: "Docker Build"
plugins:
namespace/docker-compose#v1.3.2.5:
build: app
image-repository: index.docker.io/org/repo
- wait
- name: "wrong"
command: test.sh
parallelism: 25
plugins:
github.com/buildkite/plugin-docker-compose#v1.3.2:
run: app

View file

@ -1,14 +0,0 @@
steps:
- plugins:
- docker-login#v2.0.1:
username: xyz
- docker-compose#v2.5.1:
build: app
image-repository: index.docker.io/myorg/myrepo
- wait
- command: test.sh
plugins:
- docker-login#v2.0.1:
username: xyz
- docker-compose#v2.5.1:
run: app

View file

@ -1,6 +0,0 @@
steps:
- plugins:
- ssh://git@github.company.com/some-org/some-plugin#v3.2.7:
username: abc
- https://github.company.com/some-third-org/some-third-plugin#v0.0.1:
build: app

View file

@ -1,4 +0,0 @@
steps:
- plugins:
- ssh://git@github.company.com/some-org/some-plugin.git#v3.2.7:
username: abc

View file

@ -1,8 +0,0 @@
.docker-options: &some-options
propagate-environment: true
copy-checkout: true
.python3-container: &python3-container
ssh://git@github.some-domain.com/some-org/some-plugin#v3.2.7:
some-config: some-value
<<: *some-options

View file

@ -1,4 +0,0 @@
steps:
- plugins:
- ? ssh://git@github.company.com/some-org/some-plugin.git#v3.2.7
: enforce_peer_deps: false

View file

@ -1,4 +0,0 @@
steps:
- plugins:
- ssh://git@bitbucket.org/some-org/some-plugin.git#v3.2.7:
- docker-compose#v1.3.2:

View file

@ -1,4 +1,4 @@
import { Fixtures } from '../../../../test/fixtures'; import { codeBlock } from 'common-tags';
import type { PackageDependency } from '../types'; import type { PackageDependency } from '../types';
import { extractPackageFile } from '.'; import { extractPackageFile } from '.';
@ -9,31 +9,95 @@ describe('modules/manager/buildkite/extract', () => {
}); });
it('extracts simple single plugin', () => { it('extracts simple single plugin', () => {
const res = extractPackageFile(Fixtures.get('pipeline1.yml'))?.deps; const fileContent = codeBlock`
steps:
- plugins:
abc/detect-clowns#v2.0.0: ~
`;
const res = extractPackageFile(fileContent)?.deps;
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res).toHaveLength(1); expect(res).toHaveLength(1);
}); });
it('extracts multiple plugins in same file', () => { it('extracts multiple plugins in same file', () => {
const res = extractPackageFile(Fixtures.get('pipeline2.yml'))?.deps; const fileContent = codeBlock`
steps:
# Prebuild the app image, upload it to a registry for later steps
- name: "Docker Build"
plugins:
docker-compose#v1.3.2: # Comment at the end....
build: app
image-repository: index.docker.io/org/repo
- wait
# Use the app image built above to run concurrent tests
- name: "Docker Test %n"
command: test.sh
parallelism: 25
plugins:
docker-compose#v1.3.2:
run: app
`;
const res = extractPackageFile(fileContent)?.deps;
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res).toHaveLength(2); expect(res).toHaveLength(2);
}); });
it('adds skipReason', () => { it('adds skipReason', () => {
const res = extractPackageFile(Fixtures.get('pipeline3.yml'))?.deps; const fileContent = codeBlock`
steps:
- name: "Docker Build"
plugins:
namespace/docker-compose#v1.3.2.5:
build: app
image-repository: index.docker.io/org/repo
- wait
- name: "wrong"
command: test.sh
parallelism: 25
plugins:
github.com/buildkite/plugin-docker-compose#v1.3.2:
run: app
`;
const res = extractPackageFile(fileContent)?.deps;
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res).toHaveLength(2); expect(res).toHaveLength(2);
}); });
it('extracts arrays of plugins', () => { it('extracts arrays of plugins', () => {
const res = extractPackageFile(Fixtures.get('pipeline4.yml'))?.deps; const fileContent = codeBlock`
steps:
- plugins:
- docker-login#v2.0.1:
username: xyz
- docker-compose#v2.5.1:
build: app
image-repository: index.docker.io/myorg/myrepo
- wait
- command: test.sh
plugins:
- docker-login#v2.0.1:
username: xyz
- docker-compose#v2.5.1:
run: app
`;
const res = extractPackageFile(fileContent)?.deps;
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res).toHaveLength(4); expect(res).toHaveLength(4);
}); });
it('extracts git-based plugins', () => { it('extracts git-based plugins', () => {
const res = extractPackageFile(Fixtures.get('pipeline5.yml'))?.deps; const fileContent = codeBlock`
steps:
- ssh://git@github.company.com/some-org/some-plugin#v3.2.7:
username: abc
- https://github.company.com/some-third-org/some-third-plugin#v0.0.1:
build: app
`;
const res = extractPackageFile(fileContent)?.deps;
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res).toHaveLength(2); expect(res).toHaveLength(2);
}); });
@ -45,13 +109,25 @@ describe('modules/manager/buildkite/extract', () => {
depName: 'some-org/some-plugin', depName: 'some-org/some-plugin',
registryUrls: ['https://github.company.com'], registryUrls: ['https://github.company.com'],
}; };
const res = extractPackageFile(Fixtures.get('pipeline6.yml'))?.deps; const fileContent = codeBlock`
steps:
- ssh://git@github.company.com/some-org/some-plugin.git#v3.2.7:
`;
const res = extractPackageFile(fileContent)?.deps;
expect(res).toHaveLength(1); expect(res).toHaveLength(1);
expect(res).toEqual([expectedPackageDependency]); expect(res).toEqual([expectedPackageDependency]);
}); });
it('extracts plugins outside plugins sections', () => { it('extracts plugins outside plugins sections', () => {
const res = extractPackageFile(Fixtures.get('pipeline7.yml'))?.deps; const fileContent = codeBlock`
.docker-options: &some-options
copy-checkout: true
.python3-container: &python3-container
ssh://git@github.some-domain.com/some-org/some-plugin#v3.2.7:
some-config: some-value
<<: *some-options
`;
const res = extractPackageFile(fileContent)?.deps;
const expectedPackageDependency: PackageDependency = { const expectedPackageDependency: PackageDependency = {
currentValue: 'v3.2.7', currentValue: 'v3.2.7',
datasource: 'github-tags', datasource: 'github-tags',
@ -62,7 +138,11 @@ describe('modules/manager/buildkite/extract', () => {
}); });
it('extracts plugin with preceding ?', () => { it('extracts plugin with preceding ?', () => {
const res = extractPackageFile(Fixtures.get('pipeline8.yml'))?.deps; const fileContent = codeBlock`
steps:
- ? ssh://git@github.company.com/some-org/some-plugin.git#v3.2.7
`;
const res = extractPackageFile(fileContent)?.deps;
const expectedPackageDependency: PackageDependency = { const expectedPackageDependency: PackageDependency = {
currentValue: 'v3.2.7', currentValue: 'v3.2.7',
datasource: 'github-tags', datasource: 'github-tags',
@ -73,7 +153,13 @@ describe('modules/manager/buildkite/extract', () => {
}); });
it('extracts plugin tags from bitbucket', () => { it('extracts plugin tags from bitbucket', () => {
const res = extractPackageFile(Fixtures.get('pipeline9.yml'))?.deps; const fileContent = codeBlock`
steps:
- plugins:
- ssh://git@bitbucket.org/some-org/some-plugin.git#v3.2.7:
- docker-compose#v1.3.2:
`;
const res = extractPackageFile(fileContent)?.deps;
const githubDependency: PackageDependency = { const githubDependency: PackageDependency = {
currentValue: 'v1.3.2', currentValue: 'v1.3.2',
datasource: 'github-tags', datasource: 'github-tags',