Skip to content

Commit

Permalink
Improve CI tests (#521)
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi authored Nov 9, 2024
1 parent 640665d commit 4ad234c
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Docker Tests
# Tests that require access to a cloud JFrog platform instance
name: Cloud Instance Tests
on:
push:
branches:
Expand All @@ -13,7 +14,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.ref }}
cancel-in-progress: true
jobs:
Docker-Tests:
Cloud-Tests:
if: contains(github.event.pull_request.labels.*.name, 'safe to test') || github.event_name == 'push'
runs-on: ubuntu-latest
steps:
Expand All @@ -31,4 +32,4 @@ jobs:
ADO_JFROG_PLATFORM_URL: ${{ secrets.PLATFORM_URL }}
ADO_JFROG_PLATFORM_ACCESS_TOKEN: ${{ secrets.PLATFORM_ADMIN_TOKEN }}
ADO_JFROG_PLATFORM_DOCKER_DOMAIN: ${{ secrets.CONTAINER_REGISTRY }}
ADO_SKIP_TESTS: unit,proxy,generic,installer,npm,maven,gradle,conan,nuget,dotnet,go,pip,distribution
ADO_SKIP_TESTS: unit,proxy,generic,installer,npm,maven,gradle,conan,nuget,dotnet,go,pip
33 changes: 0 additions & 33 deletions .github/workflows/distributionTests.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Tests that runs on a local Artifactory instance
name: Tests
on:
push:
Expand Down
2 changes: 1 addition & 1 deletion tests/resources/docker/pull.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let inputs = {
buildNumber: '2',
command: 'Pull',
collectBuildInfo: true,
imageName: `${platformDockerDomain}/docker-local/docker-test:1`,
imageName: `${platformDockerDomain}/${testUtils.getRepoKeys().dockerLocalRepo}/docker-test:1`,
};

testUtils.runArtifactoryTask(testUtils.docker, {}, inputs);
2 changes: 1 addition & 1 deletion tests/resources/docker/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let inputs = {
buildNumber: '1',
command: 'Push',
collectBuildInfo: true,
imageName: `${platformDockerDomain}/docker-local/docker-test:1`,
imageName: `${platformDockerDomain}/${testUtils.getRepoKeys().dockerLocalRepo}/docker-test:1`,
};

testUtils.runArtifactoryTask(testUtils.docker, {}, inputs);
2 changes: 1 addition & 1 deletion tests/resources/docker/scan.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const { platformDockerDomain } = require('../../testUtils');

let inputs = {
command: 'Scan',
imageName: `${platformDockerDomain}/docker-local/docker-test:1`,
imageName: `${platformDockerDomain}/${testUtils.getRepoKeys().dockerLocalRepo}/docker-test:1`,
};

testUtils.runXrayTask(testUtils.docker, {}, inputs);
235 changes: 130 additions & 105 deletions tests/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const repoKeys: any = {
pipRemoteRepo: 'pip-remote',
pipVirtualRepo: 'pip-virtual',
releaseBundlesRepo: 'rb-repo',
dockerLocalRepo: 'docker-local'
};

export { testDataDir, repoKeys, platformUrl, platformPassword, platformUsername, platformAccessToken, platformDockerDomain };
Expand Down Expand Up @@ -164,114 +165,138 @@ export function createTestRepositories(): void {
url: 'https://releases.jfrog.io/artifactory/jfrog-cli/v2-jf',
}),
);
createRepo(repoKeys.mavenLocalRepo, JSON.stringify({ rclass: 'local', packageType: 'maven' }));
createRepo(
repoKeys.mavenRemoteRepo,
JSON.stringify({
rclass: 'remote',
packageType: 'maven',
url: 'https://repo.maven.apache.org/maven2',
}),
);
createRepo(
repoKeys.nugetLocalRepo,
JSON.stringify({
rclass: 'local',
packageType: 'nuget',
repoLayoutRef: 'nuget-default',
}),
);
createRepo(
repoKeys.nugetRemoteRepo,
JSON.stringify({
rclass: 'remote',
packageType: 'nuget',
repoLayoutRef: 'nuget-default',
downloadContextPath: 'api/v2/package',
feedContextPath: 'api/v2',
v3FeedUrl: 'https://api.nuget.org/v3/index.json',
url: 'https://www.nuget.org/',
}),
);
createRepo(
repoKeys.nugetVirtualRepo,
JSON.stringify({
rclass: 'virtual',
packageType: 'nuget',
repoLayoutRef: 'nuget-default',
repositories: [repoKeys.nugetRemoteRepo, repoKeys.nugetLocalRepo],
}),
);
createRepo(
repoKeys.npmLocalRepo,
JSON.stringify({
rclass: 'local',
packageType: 'npm',
repoLayoutRef: 'npm-default',
}),
);
createRepo(
repoKeys.npmRemoteRepo,
JSON.stringify({
rclass: 'remote',
packageType: 'npm',
repoLayoutRef: 'npm-default',
url: 'https://registry.npmjs.org',
}),
);
createRepo(
repoKeys.npmVirtualRepo,
JSON.stringify({
rclass: 'virtual',
packageType: 'npm',
repoLayoutRef: 'npm-default',
repositories: [repoKeys.npmLocalRepo, repoKeys.npmRemoteRepo],
}),
);
createRepo(repoKeys.conanLocalRepo, JSON.stringify({ rclass: 'local', packageType: 'conan' }));
createRepo(
repoKeys.goLocalRepo,
JSON.stringify({
rclass: 'local',
packageType: 'go',
repoLayoutRef: 'go-default',
}),
);
createRepo(
repoKeys.goRemoteRepo,
JSON.stringify({
rclass: 'remote',
packageType: 'go',
repoLayoutRef: 'go-default',
url: 'https://proxy.golang.org',
}),
);
createRepo(
repoKeys.goVirtualRepo,
JSON.stringify({
rclass: 'virtual',
packageType: 'go',
repoLayoutRef: 'go-default',
repositories: [repoKeys.goLocalRepo, repoKeys.goRemoteRepo],
}),
);
createRepo(repoKeys.pipLocalRepo, JSON.stringify({ rclass: 'local', packageType: 'pypi', repoLayoutRef: 'simple-default' }));
createRepo(
repoKeys.pipRemoteRepo,
JSON.stringify({ rclass: 'remote', packageType: 'pypi', repoLayoutRef: 'simple-default', url: 'https://files.pythonhosted.org' }),
);
createRepo(
repoKeys.pipVirtualRepo,
JSON.stringify({
rclass: 'virtual',
packageType: 'pypi',
repoLayoutRef: 'simple-default',
repositories: [repoKeys.pipLocalRepo, repoKeys.pipRemoteRepo],
}),
);
if (!isSkipTest('maven')) {
createRepo(repoKeys.mavenLocalRepo, JSON.stringify({ rclass: 'local', packageType: 'maven' }));
createRepo(
repoKeys.mavenRemoteRepo,
JSON.stringify({
rclass: 'remote',
packageType: 'maven',
url: 'https://repo.maven.apache.org/maven2',
}),
);
}
if (!isSkipTest('nuget') && !isSkipTest('dotnet')) {
createRepo(
repoKeys.nugetLocalRepo,
JSON.stringify({
rclass: 'local',
packageType: 'nuget',
repoLayoutRef: 'nuget-default',
}),
);
createRepo(
repoKeys.nugetRemoteRepo,
JSON.stringify({
rclass: 'remote',
packageType: 'nuget',
repoLayoutRef: 'nuget-default',
downloadContextPath: 'api/v2/package',
feedContextPath: 'api/v2',
v3FeedUrl: 'https://api.nuget.org/v3/index.json',
url: 'https://www.nuget.org/',
}),
);
createRepo(
repoKeys.nugetVirtualRepo,
JSON.stringify({
rclass: 'virtual',
packageType: 'nuget',
repoLayoutRef: 'nuget-default',
repositories: [repoKeys.nugetRemoteRepo, repoKeys.nugetLocalRepo],
}),
);
}
if (!isSkipTest('npm')) {
createRepo(
repoKeys.npmLocalRepo,
JSON.stringify({
rclass: 'local',
packageType: 'npm',
repoLayoutRef: 'npm-default',
}),
);
createRepo(
repoKeys.npmRemoteRepo,
JSON.stringify({
rclass: 'remote',
packageType: 'npm',
repoLayoutRef: 'npm-default',
url: 'https://registry.npmjs.org',
}),
);
createRepo(
repoKeys.npmVirtualRepo,
JSON.stringify({
rclass: 'virtual',
packageType: 'npm',
repoLayoutRef: 'npm-default',
repositories: [repoKeys.npmLocalRepo, repoKeys.npmRemoteRepo],
}),
);
}
if (!isSkipTest('conan')) {
createRepo(repoKeys.conanLocalRepo, JSON.stringify({ rclass: 'local', packageType: 'conan' }));
}
if (!isSkipTest('go')) {
createRepo(
repoKeys.goLocalRepo,
JSON.stringify({
rclass: 'local',
packageType: 'go',
repoLayoutRef: 'go-default',
}),
);
createRepo(
repoKeys.goRemoteRepo,
JSON.stringify({
rclass: 'remote',
packageType: 'go',
repoLayoutRef: 'go-default',
url: 'https://proxy.golang.org',
}),
);
createRepo(
repoKeys.goVirtualRepo,
JSON.stringify({
rclass: 'virtual',
packageType: 'go',
repoLayoutRef: 'go-default',
repositories: [repoKeys.goLocalRepo, repoKeys.goRemoteRepo],
}),
);
}
if (!isSkipTest('pip')) {
createRepo(repoKeys.pipLocalRepo, JSON.stringify({ rclass: 'local', packageType: 'pypi', repoLayoutRef: 'simple-default' }));
createRepo(
repoKeys.pipRemoteRepo,
JSON.stringify({ rclass: 'remote', packageType: 'pypi', repoLayoutRef: 'simple-default', url: 'https://files.pythonhosted.org' }),
);
createRepo(
repoKeys.pipVirtualRepo,
JSON.stringify({
rclass: 'virtual',
packageType: 'pypi',
repoLayoutRef: 'simple-default',
repositories: [repoKeys.pipLocalRepo, repoKeys.pipRemoteRepo],
}),
);
}
if (!isSkipTest('distribution')) {
createRepo(repoKeys.releaseBundlesRepo, JSON.stringify({ rclass: 'releaseBundles' }));
}
if (!isSkipTest('docker')) {
createRepo(
repoKeys.dockerLocalRepo,
JSON.stringify({
rclass: 'local',
packageType: 'docker',
dockerApiVersion: 'V2',
dockerV1Enabled: false,
enableTokenAuthentication: true
}),
);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ describe('JFrog Artifactory Extension Tests', (): void => {
const filesDir: string = TestUtils.isWindows() ? 'windowsFiles' : 'unixFiles';

// Run docker build + tag
execSync(`docker build -t ${platformDockerDomain}/docker-local/docker-test:1 ${join(__dirname, 'resources', testDir, filesDir)}`);
execSync(`docker build -t ${platformDockerDomain}/${repoKeys.dockerLocalRepo}/docker-test:1 ${join(__dirname, 'resources', testDir, filesDir)}`);

// run docker push
mockTask(testDir, 'push');
Expand Down

0 comments on commit 4ad234c

Please sign in to comment.