Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trying different workflows #1396

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions .github/workflows/build-backend.yml

This file was deleted.

91 changes: 0 additions & 91 deletions .github/workflows/build-python-client.yml

This file was deleted.

228 changes: 228 additions & 0 deletions .github/workflows/build_backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#calling-a-reusable-workflow
# https://docs.github.com/fr/actions/using-workflows/workflow-syntax-for-github-actions#exemple--inclusion-de-chemins-dacc%C3%A8s

name: Full CI
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
inputs:
run-integration-tests:
description: 'If integration test should be run'
required: true
type: boolean
default: false
workflow_call:
inputs:
run-integration-tests:
description: 'If integration test should be run'
required: true
type: boolean
default: false
env:
GSK_DISABLE_ANALYTICS: true
defaults:
run:
shell: bash
jobs:
pre-check:
name: Pre check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# Inspired from https://blog.pantsbuild.org/skipping-github-actions-jobs-without-breaking-branch-protection/
- id: files
name: Get changed files outside python-client
uses: tj-actions/changed-files@v39
with:
files_ignore: python-client/**

- id: files-python
name: Get changed files in python-client
uses: tj-actions/changed-files@v39
with:
files: python-client/**

- id: python_only
if: steps.files.outputs.any_changed != 'true'
name: Check for changes in python only
run: echo 'python_only=PYTHON_ONLY' >> $GITHUB_OUTPUT

- id: python_at_least
if: steps.files-python.outputs.any_changed != 'true'
name: Check for changes in python
run: echo 'python_at_least=PYTHON_AT_LEAST' >> $GITHUB_OUTPUT

sonar:
if: ${{ github.actor != 'dependabot[bot]' && (github.event_name == 'pull_request' || github.event_name == 'push') }}
name: Sonar
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Setup Gradle # To cache ~/.gradle
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false

- name: Cache SonarQube packages
uses: actions/cache@v3
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar

- name: Analyze with Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew sonar --info --parallel

build:
needs: pre-check
if: ${{ needs.pre-check.outputs.python_only != 'PYTHON_ONLY' }}
name: Backend
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17

- name: Setup Gradle # To cache ~/.gradle
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false

- name: Cache Frontend dependencies
uses: actions/cache@v3
with:
path: frontend/node_modules
key: ${{ runner.os }}-frontend-${{ hashFiles('frontend/package-lock.json')}}
restore-keys: ${{ runner.os }}-frontend

- uses: actions/setup-node@v3
with:
node-version: 16

- name: Build frontend
run: ./gradlew :frontend:build

- name: Build backend
run: ./gradlew :backend:build --info --parallel

- name: Unit test
run: ./gradlew :backend:test :backend:jacocoTestReport --info --parallel

- name: Integration tests
run: ./gradlew :backend:integrationTest --info --parallel

# Integration Test using postgresql using test-container
- uses: docker-practice/actions-setup-docker@master
if: ${{ inputs.run-integration-tests }}

- name: Integration test under emulated production env
if: ${{ inputs.run-integration-tests }}
run: ./gradlew :backend:integrationTest --info -Ptestcontainers

build-python:
name: Build Python
needs: pre-check
if: ${{ needs.pre-check.outputs.python_at_least != 'PYTHON_AT_LEAST' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Do not stop when any job fails
matrix:
python-version: [ "3.8", "3.9", "3.10" ]
os: [ubuntu-latest]
experimental: [false]
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
include:
- python-version: "3.10"
os: windows-2019
experimental: false
continue-on-error: ${{ matrix.experimental }} # https://ncorti.com/blog/howto-github-actions-build-matrix
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Cache Python deps
uses: actions/cache@v3
with:
path: python-client/.venv
key: ${{ matrix.os }}-${{ matrix.python-version }}-python-deps-${{ hashFiles('python-client/tests/fixtures/**/*py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-python-deps

- name: Setup PDM
uses: pdm-project/setup-pdm@v3
with:
python-version: ${{ matrix.python-version }}
cache: false # TODO(Bazire): https://linear.app/giskard/issue/GSK-1712/activate-cache-on-pdm-setup-in-github-action

- name: Set up Pandoc (needed for python-client doc)
uses: r-lib/actions/setup-pandoc@v2
with:
pandoc-version: '3.1.7' # https://github.com/jgm/pandoc/releases

- name: Cache Giskard test resources
uses: actions/cache@v3
with:
path: ~/.giskard
key: ${{ matrix.os }}-${{ matrix.python-version }}-python-test-resources-${{ hashFiles('python-client/tests/fixtures/**/*py')}}
restore-keys: ${{ matrix.os }}-${{ matrix.python-version }}-python-giskard-test-resources

- name: Install dependencies
working-directory: python-client
run: pdm install -G :all

- name: Lint code
working-directory: python-client
run: pdm run lint

- name: Test code
working-directory: python-client
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: ${{ matrix.os == 'windows-2019' && 1 || 2 }}
run: pdm run test-fast

- name: Build doc
if : ${{ matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'}}
working-directory: python-client
run: pdm run doc

- name: Build
working-directory: python-client
run: pdm build

- name: "Python client: archive built artifacts"
if: ${{ github.event.event_name == 'push' && matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10' }}
uses: actions/upload-artifact@v3
with:
path: python-client/dist/*whl

- name: Run integration tests for python
if: ${{ inputs.run-integration-tests }}
working-directory: python-client
env:
PYTEST_XDIST_AUTO_NUM_WORKERS: ${{ matrix.os == 'windows-2019' && 1 || 2 }}
run: pdm run test
Loading