Skip to content

Commit

Permalink
ci: fix changed file check
Browse files Browse the repository at this point in the history
Signed-off-by: Lenin Mehedy <lenin.mehedy@swirldslabs.com>
  • Loading branch information
leninmehedy committed Jan 26, 2024
1 parent f412c4e commit ee3c7d1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
33 changes: 15 additions & 18 deletions .github/workflows/zxc-compile-code.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,12 @@ jobs:
echo " - ${file} was changed"
done
echo ""
echo "Before: ${INPUT_ENABLE-UNIT-TESTS}"
if [ "${{ steps.changed-files.outputs.source_any_changed }}" ]; then
INPUT_ENABLE-UNIT-TESTS=true
echo "run-tests=true" >> "${GITHUB_OUTPUT}"
echo "Enabled execution of java unit tests...."
else
INPUT_ENABLE-UNIT-TESTS=false
echo ">> No relevant files are changed. No need to run java unit tests"
fi
echo "After: ${INPUT_ENABLE-UNIT-TESTS}"
- name: Setup Make
run: |
Expand Down Expand Up @@ -148,7 +145,7 @@ jobs:

- name: Docker Prune
id: docker-prune
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() && !failure() }}
run: |
docker info
docker ps -a
Expand All @@ -157,7 +154,7 @@ jobs:
- name: Setup Kind
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
node_image: kindest/node:v1.27.3@sha256:3966ac761ae0136263ffdb6cfd4db23ef8a83cba8a463690e98317add2c9ba72
config: dev/dev-cluster.yaml
Expand All @@ -167,13 +164,13 @@ jobs:

- name: Setup Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
version: "v3.12.3" # helm version

# Technically, this step is not required for the unit tests to run, but it is useful for debugging setup issues.
- name: Kubernetes Cluster Info
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() && !failure() }}
run: |
kubectl config get-contexts
kubectl get crd
Expand All @@ -184,7 +181,7 @@ jobs:
- name: Authenticate to Google Cloud
id: google-auth
uses: google-github-actions/auth@67e9c72af6e0492df856527b474995862b7b6591 # v2.0.0
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
token_format: 'access_token'
workload_identity_provider: "projects/101730247931/locations/global/workloadIdentityPools/hedera-registry-pool/providers/hedera-registry-gh-actions"
Expand All @@ -193,7 +190,7 @@ jobs:
# This step is currently required because the Hedera Services artifacts are not publicly accessible.
# May be removed once the artifacts are publicly accessible.
- name: Setup Google Cloud SDK
if: ${{ inputs.enable-unit-tests && !cancelled() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() }}
uses: google-github-actions/setup-gcloud@825196879a077b7efa50db2e88409f44de4635c2 # v2.0.0

- name: Compile
Expand Down Expand Up @@ -247,7 +244,7 @@ jobs:

# This step is to cache the helm charts before we start unit tests
- name: Setup Helm Charts
if: ${{ inputs.enable-unit-tests && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() && !failure() }}
run: |
helm repo add haproxytech https://haproxytech.github.io/helm-charts
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
Expand All @@ -256,15 +253,15 @@ jobs:
- name: Unit Tests
id: gradle-test
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: check --scan

- name: Examples Unit Tests
id: gradle-test-examples
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build-examples.conclusion == 'success' && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && steps.gradle-build-examples.conclusion == 'success' && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: check --scan
Expand All @@ -273,15 +270,15 @@ jobs:
- name: Gradle Plugin Unit Tests
id: gradle-test-gradle-plugin
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() && !failure() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: check --scan
build-root-directory: fullstack-gradle-plugin

- name: Publish Unit Test Report
uses: actionite/publish-unit-test-result-action@1e01e49081c6c4073913aa4b7980fa83e709f322 # v2.3.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() && !failure() }}
with:
check_name: 'Unit Test Results'
check_run_disabled: false
Expand All @@ -292,21 +289,21 @@ jobs:
# here to prevent failures if future modules are not wired properly.
- name: Jacoco Coverage Report
uses: gradle/gradle-build-action@87a9a15658c426a54dd469d4fc7dc1a73ca9d4a6 # v2.10.0
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() }}
with:
gradle-version: ${{ inputs.gradle-version }}
arguments: jacocoTestReport --scan

- name: Publish Jacoco Coverage Report
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: ${{ inputs.enable-unit-tests && !cancelled() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() }}
with:
name: Coverage Reports
path: '**/jacocoTestReport.xml'

- name: Publish Test Reports
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
if: ${{ inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && steps.gradle-build.conclusion == 'success' && steps.gradle-build-examples.conclusion == 'success' && steps.gradle-build-gradle-plugin.conclusion == 'success' && !cancelled() }}
with:
name: Test Reports
path: "**/build/reports/tests/**"
2 changes: 1 addition & 1 deletion .github/workflows/zxc-helm-chart-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
- name: Checkout Code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
if: ${{ steps.check-changed-files.outputs.run-tests && !cancelled() && !failure() }}
if: ${{ steps.check-changed-files.outputs.run-tests && inputs.enable-unit-tests && !cancelled() && !failure() }}
with:
# the fetch depth defaults to only the commit that triggered the workflow unless the spotless check was enabled
fetch-depth: ${{ inputs.enable-spotless-check && '0' || '' }}
Expand Down

0 comments on commit ee3c7d1

Please sign in to comment.