Skip to content

Commit

Permalink
[CI] Add codecov (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomuDeuxfois authored Dec 5, 2023
1 parent b7b10e6 commit 3846585
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 114 deletions.
127 changes: 67 additions & 60 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,78 @@ kind: pipeline
name: openex-tests

steps:
- name: submodules
image: alpine/git
commands:
- git submodule update --init --recursive
- name: submodules
image: alpine/git
commands:
- git submodule update --init --recursive

- name: api-tests
image: maven:3.8.7-openjdk-18
environment:
MINIO_ENDPOINT: minio
MINIO_PORT: 9000
MINIO_ACCESS-KEY: minioadmin
MINIO_ACCESS-SECRET: minioadmin
commands:
- mvn install
- name: api-tests
image: maven:3.8.7-openjdk-18
environment:
MINIO_ENDPOINT: minio
MINIO_PORT: 9000
MINIO_ACCESS-KEY: minioadmin
MINIO_ACCESS-SECRET: minioadmin
commands:
- mvn install

- name: frontend-tests
image: nikolaik/python-nodejs:python3.10-nodejs16-alpine
- name: frontend-tests
image: nikolaik/python-nodejs:python3.10-nodejs16-alpine

commands:
- cd openex-front
- yarn install
- yarn lint
- yarn build
- NODE_OPTIONS=--max_old_space_size=8192 yarn test
commands:
- cd openex-front
- yarn install
- yarn lint
- yarn build
- NODE_OPTIONS=--max_old_space_size=8192 yarn test

- name: build-circleci
image: curlimages/curl
commands:
- curl -X POST --data "branch=master" https://circleci.com/api/v1.1/project/github/OpenEx-Platform/openex/build?circle-token=$CIRCLECI_TOKEN
environment:
CIRCLECI_TOKEN:
from_secret: circleci_token
when:
branch:
- master
event:
exclude:
- pull_request
- tag
- name: codecov
image: robertstettner/drone-codecov
settings:
token:
from_secret: CODECOV_TOKEN
files: openex-api/target/site/jacoco/jacoco.xml

- name: build-circleci-release
image: curlimages/curl
commands:
- curl -X POST --data "tag=$DRONE_TAG" https://circleci.com/api/v1.1/project/github/OpenEx-Platform/openex/build?circle-token=$CIRCLECI_TOKEN
environment:
CIRCLECI_TOKEN:
from_secret: circleci_token
when:
event:
- tag
- name: build-circleci
image: curlimages/curl
commands:
- curl -X POST --data "branch=master" https://circleci.com/api/v1.1/project/github/OpenEx-Platform/openex/build?circle-token=$CIRCLECI_TOKEN
environment:
CIRCLECI_TOKEN:
from_secret: circleci_token
when:
branch:
- master
event:
exclude:
- pull_request
- tag

- name: slack
image: plugins/slack
settings:
webhook:
from_secret: slack_webhook
username: drone
channel: notifications
when:
status: [success, failure]
- name: build-circleci-release
image: curlimages/curl
commands:
- curl -X POST --data "tag=$DRONE_TAG" https://circleci.com/api/v1.1/project/github/OpenEx-Platform/openex/build?circle-token=$CIRCLECI_TOKEN
environment:
CIRCLECI_TOKEN:
from_secret: circleci_token
when:
event:
- tag

- name: slack
image: plugins/slack
settings:
webhook:
from_secret: slack_webhook
username: drone
channel: notifications
when:
status: [ success, failure ]

services:
- name: minio
image: minio/minio:RELEASE.2021-11-09T03-21-45Z
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
command: [ server, /data ]
- name: minio
image: minio/minio:RELEASE.2023-12-02T10-51-33Z-cpuv1
environment:
MINIO_ROOT_USER: minioadmin
MINIO_ROOT_PASSWORD: minioadmin
command: [ server, /data ]
48 changes: 0 additions & 48 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

91 changes: 91 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ "master" ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ "master" ]
schedule:
- cron: '44 23 * * 5'

jobs:
analyze:
name: Analyze
# Runner size impacts CodeQL analysis time. To learn more, please see:
# - https://gh.io/recommended-hardware-resources-for-running-codeql
# - https://gh.io/supported-runners-and-hardware-resources
# - https://gh.io/using-larger-runners
# Consider using larger runners for possible analysis time improvements.
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java-kotlin', 'javascript-typescript' ]
# CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ]
# Use only 'java-kotlin' to analyze code written in Java, Kotlin or both
# Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: "true"

- name: Setup Java JDK
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 18
if: matrix.language == 'java-kotlin'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql-config.yml
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

# Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
20 changes: 20 additions & 0 deletions openex-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<opensaml.version>4.1.1</opensaml.version>
<springdoc.version>1.7.0</springdoc.version>
<springdoc-plugin.version>1.4</springdoc-plugin.version>
<jacoco-plugin.version>0.8.11</jacoco-plugin.version>
</properties>

<profiles>
Expand Down Expand Up @@ -247,6 +248,25 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package io.openex.injects.manual;

import io.openex.contract.Contract;
import io.openex.execution.Injector;
import io.openex.execution.ExecutableInject;
import io.openex.database.model.Execution;
import io.openex.execution.ExecutableInject;
import io.openex.execution.Injector;
import io.openex.model.Expectation;
import org.springframework.stereotype.Component;

Expand All @@ -12,8 +12,8 @@
@Component(ManualContract.TYPE)
public class ManualExecutor extends Injector {

@Override
public List<Expectation> process(Execution execution, ExecutableInject injection, Contract contract) {
throw new UnsupportedOperationException("Manual inject cannot be executed");
}
@Override
public List<Expectation> process(Execution execution, ExecutableInject injection, Contract contract) {
throw new UnsupportedOperationException("Manual inject cannot be executed");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.openex.injects.manual;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class ManualExecutorTest {

@Autowired
private ManualExecutor manualExecutor;


@Test
void process() {
UnsupportedOperationException error = null;
try {
this.manualExecutor.process(null, null, null);
} catch (UnsupportedOperationException e) {
error = e;
}
Assertions.assertNotNull(error);
Assertions.assertEquals("Manual inject cannot be executed", error.getMessage());
}

}

0 comments on commit 3846585

Please sign in to comment.