Add authorization #108
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 Service | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'master' | |
pull_request: | |
branches: | |
- 'master' | |
jobs: | |
changes: | |
runs-on: ubuntu-22.04 | |
permissions: | |
pull-requests: read | |
outputs: | |
service: ${{ steps.filter.outputs.service }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Check whether service (w/o chart) codebase is affected | |
uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
filters: | | |
service: | |
- '!((ephemeral-java-client|charts)/**)/**' | |
service-test: | |
runs-on: ubuntu-22.04 | |
needs: changes | |
if: ${{ needs.changes.outputs.service == 'true' }} | |
env: | |
GOPATH: ${{ github.workspace }} | |
GO111MODULE: on | |
REGISTRY: ghcr.io | |
defaults: | |
run: | |
working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }} | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}/go.mod | |
cache-dependency-path: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}/go.sum | |
- name: Perform Build | |
run: | | |
go build ./... | |
- name: Perform Tests | |
run: | | |
go test ./... -coverprofile coverage.txt.tmp && cat coverage.txt.tmp | grep -Ev "fake|helper" > coverage.txt | |
- name: Publishing Coverage | |
uses: codecov/codecov-action@v3 | |
with: | |
name: codecov | |
files: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}/coverage.txt | |
token: ${{ secrets.CODECOV_TOKEN }} | |
flags: service | |
# 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. | |
service-test-status: | |
runs-on: ubuntu-22.04 | |
needs: service-test | |
if: '!cancelled()' # Makes the job run regardless whether 'test' succeeds or not but allows for cancellation | |
steps: | |
- name: Tests successful | |
if: ${{ !(contains(needs.service-test.result, 'failure')) }} | |
run: exit 0 | |
- name: Tests failed | |
if: ${{ contains(needs.service-test.result, 'failure') }} | |
run: exit 1 |