Skip to content

Feature/update sonar #154

Feature/update sonar

Feature/update sonar #154

Workflow file for this run

# Description
# ===========
# This workflow builds a docker image each time
# commits are pushed to GitHub or a pull request is opened.
# It also runs a container of this image to test it.
---
name: CI
# This workflow is triggered each time commits are pushed to GitHub
# and also on each pull request (on the commit that would be created
# after the merge) but is not triggered if only markdown files were edited.
on:
push:
branches:
- '*'
paths-ignore:
- '*.md'
pull_request:
branches:
- '*'
paths-ignore:
- '*.md'
# Variables to configure the workflow
env:
DOCKERFILE_PATH: '.'
DOCKERFILE_FILENAME: 'Dockerfile'
DOCKER_IMAGE_NAME: 'lequal/sonar-scanner-catlab'
jobs:
# Job that builds the image and upload it as an artifact
build:
name: Build the docker image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Build docker image
run: docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_PATH
- name: Save Docker image
run: docker image save -o image.tar $DOCKER_IMAGE_NAME
- name: Upload image as an artifact
uses: actions/upload-artifact@v4
with:
name: image
path: image.tar
# Jobs that test the image and the embedded tools
test:
name: Test the Docker image
runs-on: ubuntu-22.04
needs: build
steps:
- uses: actions/checkout@v4
- name: Retrieve the image
uses: actions/download-artifact@v4
with:
name: image
- name: Load the image
run: docker image load -i image.tar
- name: Cache sonar-scanner data
uses: actions/cache@v4
with:
path: .sonarcache
key: sonar-scanner-cache
# Run the tests (with the appropriate server image)
- name: Test docker image
run: |
echo "Retrieving the sonarqube-catlab image..."
docker pull lequal/sonarqube-catlab:latest
echo "Testing the scanner image..."
cd tests/
pip install -r requirements.txt
pytest -v