From 38465854cc3f6bc5f3f886f208d525339054bd87 Mon Sep 17 00:00:00 2001 From: Romuald Lemesle Date: Tue, 5 Dec 2023 09:34:52 +0100 Subject: [PATCH] [CI] Add codecov (#342) --- .drone.yml | 127 +++++++++--------- .github/workflows/codeql-analysis.yml | 48 ------- .github/workflows/codeql.yml | 91 +++++++++++++ openex-api/pom.xml | 20 +++ .../openex/injects/manual/ManualExecutor.java | 12 +- .../injects/manual/ManualExecutorTest.java | 27 ++++ 6 files changed, 211 insertions(+), 114 deletions(-) delete mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/codeql.yml create mode 100644 openex-api/src/test/java/io/openex/injects/manual/ManualExecutorTest.java diff --git a/.drone.yml b/.drone.yml index 9d32cafd36..a4b10c1303 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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 ] diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 7e7316a3be..0000000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [master] - pull_request: - # The branches below must be a subset of the branches above - branches: [master] - paths-ignore: - - '**/*.md' - - '**/*.txt' - schedule: - - cron: "21 11 * * 0" - -jobs: - analyze: - name: Analyze - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - language: ["javascript", "java"] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] - - steps: - - name: Setup Java JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 18 - - - name: Checkout repository - uses: actions/checkout@v4 - with: - submodules: "true" - - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - config-file: ./.github/codeql-config.yml - - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..2b6f266f16 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -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}}" diff --git a/openex-api/pom.xml b/openex-api/pom.xml index cb5a8207d3..d896ecdf26 100644 --- a/openex-api/pom.xml +++ b/openex-api/pom.xml @@ -23,6 +23,7 @@ 4.1.1 1.7.0 1.4 + 0.8.11 @@ -247,6 +248,25 @@ + + org.jacoco + jacoco-maven-plugin + ${jacoco-plugin.version} + + + + prepare-agent + + + + report + test + + report + + + + org.springdoc springdoc-openapi-maven-plugin diff --git a/openex-api/src/main/java/io/openex/injects/manual/ManualExecutor.java b/openex-api/src/main/java/io/openex/injects/manual/ManualExecutor.java index be9221d6d4..5600bc11cc 100644 --- a/openex-api/src/main/java/io/openex/injects/manual/ManualExecutor.java +++ b/openex-api/src/main/java/io/openex/injects/manual/ManualExecutor.java @@ -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; @@ -12,8 +12,8 @@ @Component(ManualContract.TYPE) public class ManualExecutor extends Injector { - @Override - public List process(Execution execution, ExecutableInject injection, Contract contract) { - throw new UnsupportedOperationException("Manual inject cannot be executed"); - } + @Override + public List process(Execution execution, ExecutableInject injection, Contract contract) { + throw new UnsupportedOperationException("Manual inject cannot be executed"); + } } diff --git a/openex-api/src/test/java/io/openex/injects/manual/ManualExecutorTest.java b/openex-api/src/test/java/io/openex/injects/manual/ManualExecutorTest.java new file mode 100644 index 0000000000..56b5af4ddd --- /dev/null +++ b/openex-api/src/test/java/io/openex/injects/manual/ManualExecutorTest.java @@ -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()); + } + +}