Github Actions

To use FlowCov with GitHub Actions, you need to integrate it into your existing workflow, after the build step. In this document we will outline the steps required to do so.

Secret Management

You should always save your credentials, in this case your API Key and optionally your Repository ID, in GitHub Secrets. That way everyone can use it, but it's not possible to copy and abuse them. They will also be censored in the build logs.

You can find the required steps to create new secrets in the GitHub documentation. In this document, we will assume that you stored them into the following secrets:

  • FLOWCOV_API_KEY
  • FLOWCOV_REPOSITORY_ID

Integrate it into an existing workflow

You can use the following snippet as an additional step in your existing workflow. Remember that it has to be executed after you run your tests.

.github/workflows/build.yaml
- name: Upload Workflow Coverage
run: >-
bash <(curl -s https://bash.flowcov.io)
env:
FLOWCOV_API_KEY: ${{ secrets.FLOWCOV_API_KEY }}
FLOWCOV_REPOSITORY_ID: ${{ secrets.FLOWCOV_REPOSITORY_ID }}

This snippet downloads the latest version of the script, and executes it using the API key and repository ID provided in the environment variables described above.

Creating a new workflow

If you don't have a workflow defined yet, you can use the following instead. Store it as a new file called .github/workflows/build.yaml in your repository's root directory. It will then automatically be run the next time you push a commit.

It builds your source code using Ubuntu, Java 11, and Gradle as build environment. It then executes the script as described above. For more details on how to define your custom actions, see the GitHub documentation.

.github/workflows/build.yaml
name: Build & Test
on:
push:
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Sources
uses: actions/checkout@v2
- name: Setup Java 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Build and Test Application
run: >-
./gradlew build
- name: Upload Workflow Coverage
run: >-
bash <(curl -s https://bash.flowcov.io)
env:
FLOWCOV_API_KEY: ${{ secrets.FLOWCOV_API_KEY }}
FLOWCOV_REPOSITORY_ID: ${{ secrets.FLOWCOV_REPOSITORY_ID }}