Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TG-21003] Add action per supported JDK version #109

Merged
merged 3 commits into from
Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
Build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Build
run: |
# Rebuild per-JDK actions based on the base content
./build.sh
# Fail CI if rebuilding left uncommitted changes
if [ "$(git status --porcelain | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git status
exit 1
fi
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,19 @@ This project provides a GitHub Action for running Diffblue Cover.
- [Diffblue Privacy Notice](https://docs.diffblue.com/legal/diffblue-legal/privacy-notice)
- [Request Diffblue trial license](https://www.diffblue.com/try-cover/github)

## Variants

Multiple variants of the docker action are available using different JDK versions.
The base version currently uses JDK17 but this may change.
In general it's recommended to specify the action with your chosen JDK:

- `diffblue/cover-github-action@main`
- `diffblue/cover-github-action/jdk8@main`
- `diffblue/cover-github-action/jdk11@main`
- `diffblue/cover-github-action/jdk17@main`
- `diffblue/cover-github-action/jdk21@main`

Variants are maintained using the `build.sh` script to ensure that they only vary by JDK from the base version.

## Usage

2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Diffblue Cover
description:
Runs Diffblue Cover to automatically write and maintain Java unit tests.
Variations of the action are available using various supported JDK versions.
This variation uses JDK17.
author: Diffblue
branding:
icon: check-circle
18 changes: 18 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
set +x

# The JDK version string referenced in the base directory
JDKBASE=JDK17
jdkbase=$(echo $JDKBASE | tr '[:upper:]' '[:lower:]')

# For each JDK version to be supported in a separate directory
for JDK in "JDK8" "JDK11" "JDK17" "JDK21"; do
jdk=$(echo $JDK | tr '[:upper:]' '[:lower:]')

mkdir -p $jdk/

for file in action.yml entrypoint.sh Dockerfile; do
echo "Updating $jdk/$file"
cat $file | sed -e s/$JDKBASE/$JDK/g -e s/$jdkbase/$jdk/g > $jdk/$file
done
done
13 changes: 13 additions & 0 deletions jdk11/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Default to using the latest version of Diffblue Cover on JDK11
# Additional images are available for specific Diffblue Cover
# versions and JDK versions.
FROM diffblue/cover-cli:latest-jdk11

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Record the image-specific environment for later
RUN env > /.env

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
43 changes: 43 additions & 0 deletions jdk11/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Diffblue Cover
description:
Runs Diffblue Cover to automatically write and maintain Java unit tests.
Variations of the action are available using various supported JDK versions.
This variation uses JDK11.
author: Diffblue
branding:
icon: check-circle
color: blue
inputs:
license-key:
required: true
description:
The license key provided in your welcome email or provided by your organization.
Alternatively obtain a free trial key from https://www.diffblue.com/try-cover/github.
access-token:
required: true
description:
The access token used to push commits and call GitHub APIs.

Must have access to the project with at least Write role, and scopes
including code, commit-statuses, pull-requests, workflows and actions.
args:
required: false
description:
The Diffblue Cover commands and options to use.
default: >-
ci
activate
validate
create
working-directory:
required: false
description:
Working directory where the project can be found, if not at the root.
default: .
runs:
using: docker
image: Dockerfile
env:
DIFFBLUE_LICENSE_KEY: ${{ inputs.license-key }}
DIFFBLUE_WORKING_DIRECTORY: ${{ inputs.working-directory }}
DIFFBLUE_ACCESS_TOKEN: ${{ inputs.access-token }}
19 changes: 19 additions & 0 deletions jdk11/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh -l

set -ex

# Mark the workspace as safe
/usr/bin/git config --system --add safe.directory `pwd`

# Hmmmmm... fetch the next few refs just to get started
git fetch --all --deepen=5

# Reset the image-specific environment
export $(cat /.env | xargs)

# Just change directory here because it's easier than
# correctly adding --working-directory to each command
cd "${DIFFBLUE_WORKING_DIRECTORY}"

# The command to run. Should ci and activate be mandatory?
/opt/cover/dcover ${INPUT_ARGS}
13 changes: 13 additions & 0 deletions jdk17/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Default to using the latest version of Diffblue Cover on JDK17
# Additional images are available for specific Diffblue Cover
# versions and JDK versions.
FROM diffblue/cover-cli:latest-jdk17

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Record the image-specific environment for later
RUN env > /.env

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
43 changes: 43 additions & 0 deletions jdk17/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Diffblue Cover
description:
Runs Diffblue Cover to automatically write and maintain Java unit tests.
Variations of the action are available using various supported JDK versions.
This variation uses JDK17.
author: Diffblue
branding:
icon: check-circle
color: blue
inputs:
license-key:
required: true
description:
The license key provided in your welcome email or provided by your organization.
Alternatively obtain a free trial key from https://www.diffblue.com/try-cover/github.
access-token:
required: true
description:
The access token used to push commits and call GitHub APIs.

Must have access to the project with at least Write role, and scopes
including code, commit-statuses, pull-requests, workflows and actions.
args:
required: false
description:
The Diffblue Cover commands and options to use.
default: >-
ci
activate
validate
create
working-directory:
required: false
description:
Working directory where the project can be found, if not at the root.
default: .
runs:
using: docker
image: Dockerfile
env:
DIFFBLUE_LICENSE_KEY: ${{ inputs.license-key }}
DIFFBLUE_WORKING_DIRECTORY: ${{ inputs.working-directory }}
DIFFBLUE_ACCESS_TOKEN: ${{ inputs.access-token }}
19 changes: 19 additions & 0 deletions jdk17/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh -l

set -ex

# Mark the workspace as safe
/usr/bin/git config --system --add safe.directory `pwd`

# Hmmmmm... fetch the next few refs just to get started
git fetch --all --deepen=5

# Reset the image-specific environment
export $(cat /.env | xargs)

# Just change directory here because it's easier than
# correctly adding --working-directory to each command
cd "${DIFFBLUE_WORKING_DIRECTORY}"

# The command to run. Should ci and activate be mandatory?
/opt/cover/dcover ${INPUT_ARGS}
13 changes: 13 additions & 0 deletions jdk21/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Default to using the latest version of Diffblue Cover on JDK21
# Additional images are available for specific Diffblue Cover
# versions and JDK versions.
FROM diffblue/cover-cli:latest-jdk21

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Record the image-specific environment for later
RUN env > /.env

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
43 changes: 43 additions & 0 deletions jdk21/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Diffblue Cover
description:
Runs Diffblue Cover to automatically write and maintain Java unit tests.
Variations of the action are available using various supported JDK versions.
This variation uses JDK21.
author: Diffblue
branding:
icon: check-circle
color: blue
inputs:
license-key:
required: true
description:
The license key provided in your welcome email or provided by your organization.
Alternatively obtain a free trial key from https://www.diffblue.com/try-cover/github.
access-token:
required: true
description:
The access token used to push commits and call GitHub APIs.

Must have access to the project with at least Write role, and scopes
including code, commit-statuses, pull-requests, workflows and actions.
args:
required: false
description:
The Diffblue Cover commands and options to use.
default: >-
ci
activate
validate
create
working-directory:
required: false
description:
Working directory where the project can be found, if not at the root.
default: .
runs:
using: docker
image: Dockerfile
env:
DIFFBLUE_LICENSE_KEY: ${{ inputs.license-key }}
DIFFBLUE_WORKING_DIRECTORY: ${{ inputs.working-directory }}
DIFFBLUE_ACCESS_TOKEN: ${{ inputs.access-token }}
19 changes: 19 additions & 0 deletions jdk21/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh -l

set -ex

# Mark the workspace as safe
/usr/bin/git config --system --add safe.directory `pwd`

# Hmmmmm... fetch the next few refs just to get started
git fetch --all --deepen=5

# Reset the image-specific environment
export $(cat /.env | xargs)

# Just change directory here because it's easier than
# correctly adding --working-directory to each command
cd "${DIFFBLUE_WORKING_DIRECTORY}"

# The command to run. Should ci and activate be mandatory?
/opt/cover/dcover ${INPUT_ARGS}
13 changes: 13 additions & 0 deletions jdk8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Default to using the latest version of Diffblue Cover on JDK8
# Additional images are available for specific Diffblue Cover
# versions and JDK versions.
FROM diffblue/cover-cli:latest-jdk8

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /entrypoint.sh

# Record the image-specific environment for later
RUN env > /.env

# Code file to execute when the docker container starts up (`entrypoint.sh`)
ENTRYPOINT ["/entrypoint.sh"]
43 changes: 43 additions & 0 deletions jdk8/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Diffblue Cover
description:
Runs Diffblue Cover to automatically write and maintain Java unit tests.
Variations of the action are available using various supported JDK versions.
This variation uses JDK8.
author: Diffblue
branding:
icon: check-circle
color: blue
inputs:
license-key:
required: true
description:
The license key provided in your welcome email or provided by your organization.
Alternatively obtain a free trial key from https://www.diffblue.com/try-cover/github.
access-token:
required: true
description:
The access token used to push commits and call GitHub APIs.

Must have access to the project with at least Write role, and scopes
including code, commit-statuses, pull-requests, workflows and actions.
args:
required: false
description:
The Diffblue Cover commands and options to use.
default: >-
ci
activate
validate
create
working-directory:
required: false
description:
Working directory where the project can be found, if not at the root.
default: .
runs:
using: docker
image: Dockerfile
env:
DIFFBLUE_LICENSE_KEY: ${{ inputs.license-key }}
DIFFBLUE_WORKING_DIRECTORY: ${{ inputs.working-directory }}
DIFFBLUE_ACCESS_TOKEN: ${{ inputs.access-token }}
19 changes: 19 additions & 0 deletions jdk8/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh -l

set -ex

# Mark the workspace as safe
/usr/bin/git config --system --add safe.directory `pwd`

# Hmmmmm... fetch the next few refs just to get started
git fetch --all --deepen=5

# Reset the image-specific environment
export $(cat /.env | xargs)

# Just change directory here because it's easier than
# correctly adding --working-directory to each command
cd "${DIFFBLUE_WORKING_DIRECTORY}"

# The command to run. Should ci and activate be mandatory?
/opt/cover/dcover ${INPUT_ARGS}