diff --git a/README.md b/README.md index da9fd23..0480474 100644 --- a/README.md +++ b/README.md @@ -20,14 +20,14 @@ The `Approve and Run` manual step documented [here](https://docs.github.com/en/a **Usage**: -In the GitHub workflow called to validate a pull-request, insert the `Setup build scan capture` once in each job having steps invoking Maven. +In the GitHub workflow called to validate a pull-request, insert the `Setup Maven Build Scan dump capture` once in each job having steps invoking Maven. ```yaml name: PR Build jobs: build: - - name: Setup Build Scan dump capture - uses: gradle/github-actions/maven-build-scan-capture@v1-beta + - name: Setup Maven Build Scan dump capture + uses: gradle/github-actions/maven-build-scan-setup@v1-beta - name: Build with Maven run: mvn clean package [...] @@ -52,7 +52,7 @@ jobs: pull-requests: write steps: - name: Setup Build Scan link capture - uses: gradle/github-actions/maven-build-scan-capture@v1-beta + uses: gradle/github-actions/maven-build-scan-setup@v1-beta - name: Publish Build Scans uses: gradle/github-actions/maven-build-scan-publish@v1-beta with: @@ -68,7 +68,7 @@ Some parameters need to be adjusted here: ### Implementation details -#### maven-build-scan-capture +#### maven-build-scan-setup The action addresses two use cases: - Save unpublished Build ScanĀ® data as a workflow artifact with name `maven-build-scan-data`, which can then be published in a dependent workflow. @@ -87,7 +87,7 @@ The process is handled by a [Maven extension](https://maven.apache.org/guides/mi The extension must be registered at the beginning of the GitHub workflow job, by copying it in `$MAVEN_HOME/lib/ext/`. The `MAVEN_HOME` environment variable is used if present, otherwise, the csv list of folders `maven-home-search-patterns` is searched. This variable van be configured. -`workflow-filename` and `job-filename` are only used in the summary rendered by the `maven-build-scan-capture` action. Default values can be overridden, which is highly recommended when using a [matrix strategy](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs) as those values would collide on each matrix case. +`workflow-filename` and `job-filename` are only used in the summary rendered by the `maven-build-scan-publish` action. Default values can be overridden, which is highly recommended when using a [matrix strategy](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs) as those values would collide on each matrix case. **Event Triggers**: @@ -107,7 +107,7 @@ The `MAVEN_HOME` environment variable is used if present, otherwise, the csv lis **Usage**: -Insert the `Setup build scan capture` once in each job having steps invoking Maven. +Insert the `Setup Maven Build Scan dump capture` once in each job having steps invoking Maven. ```yaml name: PR Build @@ -115,8 +115,8 @@ jobs: [...] build: [...] - - name: Setup Build Scan dump capture - uses: gradle/github-actions/maven-build-scan-capture@v1-beta + - name: Setup Maven Build Scan dump capture + uses: gradle/github-actions/maven-build-scan-setup@v1-beta - name: Build with Maven run: mvn clean package [...] @@ -212,8 +212,8 @@ jobs: actions: write pull-requests: write steps: - - name: Setup Build Scan link capture - uses: gradle/github-actions/maven-build-scan-capture@v1-beta + - name: Setup Maven Build Scan link capture + uses: gradle/github-actions/maven-build-scan-setup@v1-beta - name: Publish Build Scans uses: gradle/github-actions/maven-build-scan-publish@v1-beta with: diff --git a/doc/architecture.png b/doc/architecture.png index 09e24ba..cab4328 100644 Binary files a/doc/architecture.png and b/doc/architecture.png differ diff --git a/maven-build-scan-capture-extension/dist/maven-build-scan-capture-extension.jar b/maven-build-scan-capture-extension/dist/maven-build-scan-capture-extension.jar index 181b8c1..ce3a0c1 100644 Binary files a/maven-build-scan-capture-extension/dist/maven-build-scan-capture-extension.jar and b/maven-build-scan-capture-extension/dist/maven-build-scan-capture-extension.jar differ diff --git a/maven-build-scan-publish/action.yml b/maven-build-scan-publish/action.yml index 93c4867..3c4e0de 100644 --- a/maven-build-scan-publish/action.yml +++ b/maven-build-scan-publish/action.yml @@ -1,5 +1,5 @@ name: Publish Maven Build Scans action -description: Publish Maven Build Scans previously saved with the Maven Build Scan capture action +description: Publish Maven Build Scans previously saved with the Maven Build Scan setup action author: Gradle team inputs: diff --git a/maven-build-scan-capture/__tests__/main.test.ts b/maven-build-scan-setup/__tests__/main.test.ts similarity index 85% rename from maven-build-scan-capture/__tests__/main.test.ts rename to maven-build-scan-setup/__tests__/main.test.ts index 36244d5..f2d42a1 100644 --- a/maven-build-scan-capture/__tests__/main.test.ts +++ b/maven-build-scan-setup/__tests__/main.test.ts @@ -1,11 +1,13 @@ import * as github from '@actions/github' +// required before main is loaded +process.env['GITHUB_REPOSITORY'] = 'foo/bar'; +process.env['MAVEN_HOME'] = '/tmp'; + import * as main from '../src/main' import * as io from '../src/utils/io' import * as layout from '../src/utils/layout' -const runMock = jest.spyOn(main, 'run') - function githubContext() { Object.defineProperty(github, 'context', { value: { @@ -19,15 +21,19 @@ function githubContext() { } }) } +const runMock = jest.spyOn(main, 'run') + +describe('setup', () => { + beforeEach(() => { + githubContext() + }) -describe('capture', () => { afterEach(() => { jest.clearAllMocks() }) - it('Setup build scan capture succeeds', async () => { + it('Setup build scan action succeeds', async () => { // Given - githubContext() const layoutSourceMock = jest .spyOn(layout, 'mavenBuildScanCaptureExtensionSource') .mockReturnValue('sourceFileName') @@ -48,7 +54,6 @@ describe('capture', () => { it('Setup when Maven home is not found fails', async () => { // Given - githubContext() const errorMsg = 'Maven home not found' const layoutTargetMock = jest.spyOn(layout, 'mavenBuildScanCaptureExtensionTarget').mockRejectedValue(errorMsg) const ioMock = jest.spyOn(io, 'copyFileSync').mockReturnValue() @@ -58,7 +63,7 @@ describe('capture', () => { // then expect(runMock).toHaveReturned() - expect(layoutTargetMock).rejects.toEqual(errorMsg) + await expect(layoutTargetMock).rejects.toEqual(errorMsg) expect(ioMock).not.toHaveBeenCalled() }) }) diff --git a/maven-build-scan-capture/__tests__/post.test.ts b/maven-build-scan-setup/__tests__/post.test.ts similarity index 98% rename from maven-build-scan-capture/__tests__/post.test.ts rename to maven-build-scan-setup/__tests__/post.test.ts index e9b7bda..c451914 100644 --- a/maven-build-scan-capture/__tests__/post.test.ts +++ b/maven-build-scan-setup/__tests__/post.test.ts @@ -21,7 +21,7 @@ function githubContext() { }) } -describe('capture', () => { +describe('post', () => { afterEach(() => { jest.clearAllMocks() }) diff --git a/maven-build-scan-capture/action.yml b/maven-build-scan-setup/action.yml similarity index 91% rename from maven-build-scan-capture/action.yml rename to maven-build-scan-setup/action.yml index 71b3dc5..e3ecea7 100644 --- a/maven-build-scan-capture/action.yml +++ b/maven-build-scan-setup/action.yml @@ -1,5 +1,5 @@ -name: Maven Build Scan Capture action -description: Maven Build Scan Capture action +name: Maven Build Scan setup action +description: Setup action to capture Build Scans metadata author: Gradle team inputs: diff --git a/maven-build-scan-capture/dist/main/index.js b/maven-build-scan-setup/dist/main/index.js similarity index 100% rename from maven-build-scan-capture/dist/main/index.js rename to maven-build-scan-setup/dist/main/index.js diff --git a/maven-build-scan-capture/dist/post/index.js b/maven-build-scan-setup/dist/post/index.js similarity index 100% rename from maven-build-scan-capture/dist/post/index.js rename to maven-build-scan-setup/dist/post/index.js diff --git a/maven-build-scan-capture/src/main.ts b/maven-build-scan-setup/src/main.ts similarity index 100% rename from maven-build-scan-capture/src/main.ts rename to maven-build-scan-setup/src/main.ts diff --git a/maven-build-scan-capture/src/post.ts b/maven-build-scan-setup/src/post.ts similarity index 100% rename from maven-build-scan-capture/src/post.ts rename to maven-build-scan-setup/src/post.ts diff --git a/maven-build-scan-capture/src/utils/error.ts b/maven-build-scan-setup/src/utils/error.ts similarity index 100% rename from maven-build-scan-capture/src/utils/error.ts rename to maven-build-scan-setup/src/utils/error.ts diff --git a/maven-build-scan-capture/src/utils/input.ts b/maven-build-scan-setup/src/utils/input.ts similarity index 100% rename from maven-build-scan-capture/src/utils/input.ts rename to maven-build-scan-setup/src/utils/input.ts diff --git a/maven-build-scan-capture/src/utils/io.ts b/maven-build-scan-setup/src/utils/io.ts similarity index 100% rename from maven-build-scan-capture/src/utils/io.ts rename to maven-build-scan-setup/src/utils/io.ts diff --git a/maven-build-scan-capture/src/utils/layout.ts b/maven-build-scan-setup/src/utils/layout.ts similarity index 100% rename from maven-build-scan-capture/src/utils/layout.ts rename to maven-build-scan-setup/src/utils/layout.ts diff --git a/maven-build-scan-capture/tsconfig.json b/maven-build-scan-setup/tsconfig.json similarity index 100% rename from maven-build-scan-capture/tsconfig.json rename to maven-build-scan-setup/tsconfig.json diff --git a/package.json b/package.json index addd0f4..937e757 100644 --- a/package.json +++ b/package.json @@ -24,11 +24,11 @@ "format:test": "prettier --write **/__tests__/**/*.ts", "lint": "eslint */src/**/*.ts", "package-maven-build-scan-capture-extension": "mvn clean package -f maven-build-scan-capture-extension/pom.xml", - "package-maven-build-scan-capture-main": "ncc build maven-build-scan-capture/src/main.ts --out maven-build-scan-capture/dist/main", - "package-maven-build-scan-capture-post": "ncc build maven-build-scan-capture/src/post.ts --out maven-build-scan-capture/dist/post", - "package-maven-build-scan-capture": "npm run package-maven-build-scan-capture-main && npm run package-maven-build-scan-capture-post && npm run package-maven-build-scan-capture-extension", + "package-maven-build-scan-setup-main": "ncc build maven-build-scan-setup/src/main.ts --out maven-build-scan-capture/dist/main", + "package-maven-build-scan-setup-post": "ncc build maven-build-scan-setup/src/post.ts --out maven-build-scan-capture/dist/post", + "package-maven-build-scan-setup": "npm run package-maven-build-scan-setup-main && npm run package-maven-build-scan-setup-post && npm run package-maven-build-scan-capture-extension", "package-maven-build-scan-publish": "ncc build maven-build-scan-publish/src/main.ts --out maven-build-scan-publish/dist", - "package": "npm run package-maven-build-scan-capture && npm run package-maven-build-scan-publish", + "package": "npm run package-maven-build-scan-setup && npm run package-maven-build-scan-publish", "test": "jest", "all": "npm run format:write && npm run lint && npm run package && npm run test" },