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

AAE-28088 Skip tests during PR draft #811

Merged
merged 5 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
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
23 changes: 21 additions & 2 deletions .github/actions/maven-build-and-tag/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,18 @@ inputs:
description: Whether testcontainers should be reused
required: false
default: 'false'
skip-tests-label:
description: The label name for skipping tests
required: false
default: 'skip-tests'

outputs:
version:
description: "The version of the new tag created by this workflow"
value: ${{ steps.update-pom-to-next-version.outputs.next-prerelease }}
skip-tests:
description: "Whether tests were skipped during build or not"
value: ${{ steps.set-skip-tests-env-variable.outputs.skip-tests }}

runs:
using: composite
Expand All @@ -112,13 +119,24 @@ runs:
with:
maven-version: ${{ inputs.maven-version }}

- name: Set skip tests env variable
id: set-skip-tests-env-variable
env:
SKIP_TESTS: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, inputs.skip-tests-label) }}
shell: bash
run: |
echo "SKIP_TESTS=$SKIP_TESTS" >> $GITHUB_ENV
echo "skip-tests=$SKIP_TESTS" >> $GITHUB_OUTPUT

- name: Compute maven options
id: compute-maven-options
shell: bash
run: |
NTP='--no-transfer-progress'
${{ inputs.verbose }} && NTP=''
echo "result=--show-version --settings settings.xml $NTP" >> $GITHUB_OUTPUT
TEST_OPTIONS=''
[[ $SKIP_TESTS == 'true' ]] && TEST_OPTIONS='-DskipTests=true -DskipITs=true'
echo "result=--show-version --settings settings.xml $NTP $TEST_OPTIONS" >> $GITHUB_OUTPUT

- name: Set is_preview env variable
id: set-is-preview-env-variable
Expand Down Expand Up @@ -245,14 +263,15 @@ runs:
${{ inputs.upload-jars-path }}

- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
if: inputs.upload-coverage == 'true'
if: inputs.upload-coverage == 'true' && env.SKIP_TESTS != 'true'
with:
name: coverage
retention-days: 1
path: |
**/target/site/jacoco-aggregate/jacoco.xml

- name: Echo Longest Tests run
if: env.SKIP_TESTS != 'true'
shell: bash
run: find . -name TEST-*.xml -exec grep -h testcase {} \; | awk -F '"' '{printf("%s#%s() - %.3fms\n", $4, $2, $6); }' | sort -n -k 3 | tail -20

Expand Down
21 changes: 21 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,7 @@ Check out, builds a maven project and docker images, generating a new alpha vers
```yaml
outputs:
version: ${{ steps.build-and-tag.outputs.version }}
skip-tests: ${{ steps.build-and-tag.outputs.skip-tests }}
steps:
- uses: Alfresco/alfresco-build-tools/.github/actions/maven-build-and-tag@ref
id: build-and-tag
Expand All @@ -1027,6 +1028,26 @@ There is a possibility to publish snapshot maven artifacts and docker images fro
In order to use it specify `preview-label` input (or use default `preview`). Create a PR with the `preview-label` label.
The created maven artifacts and docker images will be tagged as `0.0.1-$GITHUB_PR_NUMBER-SNAPSHOT`.

#### Option to skip tests for maven-build-and-tag

There is a possibility to skip Unit and Integration Tests during build for an open PR.
In order to use it specify `skip-tests-label` input (or use default `skip-tests`). Create a PR with the `skip-tests` label.
A PR should not be merged if tests are skpped.

Sample usage to prevent merging when tests are skipped:

```yaml
- name: Set status check
shell: bash
run: |
if [[ ${{ steps.build-and-tag.outputs.skip-tests }} == 'true' ]]; then
echo "This pull request cannot be merged."
exit 1
else
echo "This pull request can be merged."
fi
```

### maven-deploy-file

Upload one or more files to a maven server, without requiring the presence of a
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v8.3.1
v8.4.0
Loading