diff --git a/.github/workflows/nightly-coverage.yml b/.github/workflows/nightly-coverage.yml new file mode 100644 index 0000000000..a6a0632aae --- /dev/null +++ b/.github/workflows/nightly-coverage.yml @@ -0,0 +1,93 @@ +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# --------------------------------------------------------------------------- + +name: coverage + +on: + schedule: + - cron: '45 1 * * *' + workflow_dispatch: + +jobs: + test: + runs-on: ubuntu-20.04 + name: Update Coverage Badge + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + persist-credentials: false + fetch-depth: 0 + + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: '1.18' + check-latest: true + + - uses: actions/cache@v3 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Run Test + run: | + go test -v ./... -covermode=count -coverprofile=coverage.out + go tool cover -func=coverage.out -o=coverage.out + touch badge.out + + - name: Go Coverage Badge + + uses: tj-actions/coverage-badge-go@v2 + with: + filename: coverage.out + target: badge.out + + - name: Convert Badge to adoc + run: | + replacement=$(grep -o 'https://[^)]*' badge.out) + target="(?:https:\/\/img\.shields\.io\/badge\/Coverage).*?(?=\.svg)" + perl -i -pe "s|${target}|${replacement}|g" README.adoc + + + - name: Verify Changed files + uses: tj-actions/verify-changed-files@v12 + id: verify-changed-files + with: + files: README.adoc + + - name: Commit changes + shell: bash + env: + CI_USER: "github-actions[bot]" + CI_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" + run: | + git config --local user.email "$CI_EMAIL" + git config --local user.name "$CI_USER" + git add -A && git commit -m 'chore: nightly coverage badge' && echo "refresh=1" >> $GITHUB_ENV || echo "No changes to make update-docs" + + - name: Push changes + shell: bash + if: env.changelog == 1 || env.refresh == 1 + env: + CI_USER: "github-actions[bot]" + CI_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com" + CI_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + git push "https://$CI_USER:$CI_TOKEN@github.com/$GITHUB_REPOSITORY.git" '${{ github.ref_name }}' \ No newline at end of file diff --git a/README.adoc b/README.adoc index 4e501fa382..d07ad3186c 100644 --- a/README.adoc +++ b/README.adoc @@ -11,6 +11,7 @@ image:https://github.com/apache/camel-k/workflows/kubernetes/badge.svg["Kubernet image:https://github.com/apache/camel-k/workflows/knative/badge.svg["Knative", link="https://github.com/apache/camel-k/actions/workflows/knative.yml"] image:https://github.com/apache/camel-k/actions/workflows/nightly-release.yml/badge.svg["Nightly releases", link="https://github.com/apache/camel-k/actions/workflows/nightly-release.yml"] image:https://github.com/apache/camel-k/actions/workflows/nightly-native-test.yml/badge.svg["Quarkus native", link="https://github.com/apache/camel-k/actions/workflows/nightly-native-test.yml"] +image:https://img.shields.io/badge/Coverage-39.6%25-yellow.svg["Go coverage", link="https://github.com/apache/camel-k/actions/workflows/nightly-coverage.yml"] image:https://img.shields.io/badge/zulip-join_chat-brightgreen.svg["Chat on Zulip", link="https://camel.zulipchat.com"] Apache Camel K is a lightweight integration framework built from **Apache Camel** that runs natively on Kubernetes and is specifically designed for serverless and microservice architectures. Users of `Camel K` can instantly run integration code written in Camel DSL on their preferred **Cloud** provider.