Skip to content

Commit

Permalink
Rename capture action to setup action
Browse files Browse the repository at this point in the history
  • Loading branch information
jprinet committed Dec 4, 2023
1 parent 71db4db commit fe8ab6a
Show file tree
Hide file tree
Showing 17 changed files with 31 additions and 26 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
[...]
Expand All @@ -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:
Expand All @@ -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.
Expand All @@ -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**:

Expand All @@ -107,16 +107,16 @@ 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
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
[...]
Expand Down Expand Up @@ -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:
Expand Down
Binary file modified doc/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
2 changes: 1 addition & 1 deletion maven-build-scan-publish/action.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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')
Expand All @@ -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()
Expand All @@ -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()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function githubContext() {
})
}

describe('capture', () => {
describe('post', () => {
afterEach(() => {
jest.clearAllMocks()
})
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down

0 comments on commit fe8ab6a

Please sign in to comment.