Skip to content

Add authorization

Add authorization #108

#
# Copyright (c) 2023 - for information on the respective copyright owner
# see the NOTICE file and/or the repository https://github.com/carbynestack/ephemeral.
#
# SPDX-License-Identifier: Apache-2.0
#
name: Build and test Java Client
on:
workflow_dispatch:
push:
branches:
- 'master'
pull_request:
branches:
- 'master'
jobs:
changes:
runs-on: ubuntu-22.04
permissions:
pull-requests: read
outputs:
java-client: ${{ steps.filter.outputs.java-client }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Check whether Java client codebase is affected
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
java-client:
- '(ephemeral-java-client|.github)/**'
java-client-test:
runs-on: ubuntu-22.04
needs: changes
if: ${{ needs.changes.outputs.java-client == 'true' }}
defaults:
run:
working-directory: ephemeral-java-client
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'
- name: Setting up Github Package Repository as Maven Repository
uses: s4u/maven-settings-action@v2
with:
githubServer: false
servers: |
[{
"id": "github",
"username": "${{ github.actor }}",
"password": "${{ secrets.GITHUB_TOKEN }}"
}]
- name: Build with Maven
run: mvn install -Dskip.tests --batch-mode --update-snapshots --no-transfer-progress
- name: Run Tests
run: mvn verify --activate-profiles coverage --batch-mode --no-transfer-progress
- name: Collect Jacoco reports
run: echo ::set-output name=reports::$(find . -regex 'target/site/jacoco/jacoco.xml' | tr '\n' ',' | sed 's/.$//')
id: jacoco
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ steps.jacoco.outputs.reports }}
flags: java-client
name: codecov
# This is required to allow for setting the test job as required in scenarios
# where the tests are not actually run, e.g., when the helm chart is updated.
java-client-test-status:
runs-on: ubuntu-22.04
needs: java-client-test
if: '!cancelled()' # Makes the job run regardless whether 'test' succeeds or not but allows for cancellation
steps:
- name: Tests successful
if: ${{ !(contains(needs.java-client-test.result, 'failure')) }}
run: exit 0
- name: Tests failed
if: ${{ contains(needs.java-client-test.result, 'failure') }}
run: exit 1