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

ci: Add GH workflow #33

Closed
wants to merge 1 commit into from
Closed
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
161 changes: 161 additions & 0 deletions .github/workflows/run_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '20 0 * * *'

env:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
JAVA_TOOL_OPTIONS: ""
SECRET_DETECTION_JSON_REPORT_FILE: "gitleaks.json"
SECRET_DETECTION_JUNIT_REPORT_FILE: "gitleaks.xml"
SECRET_DETECTION_FAIL_ON_SECRET: "true"

jobs:
spotless:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Spotless check
run: ./gradlew spotlessCheck

license_check:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: License check
run: |
./license_checker.sh '*.java' | tee license_check_output.txt
[ ! -s license_check_output.txt ]

secret_detection:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install and run secret detection
run: |
pwd
ls -alh
wget https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz
tar -xzf gitleaks_8.18.4_linux_x64.tar.gz
EXITCODE=0
./gitleaks detect -r ${SECRET_DETECTION_JSON_REPORT_FILE} --source ${HOME}/work/deepl-java/deepl-java --log-opts="--all --full-history" || EXITCODE=$?
if [[ $EXITCODE -ne 0 ]]; then
exit $EXITCODE
fi
- name: Upload secret detection artifact
uses: actions/upload-artifact@v4
with:
name: secret-detection-results
path: ${SECRET_DETECTION_JSON_REPORT_FILE}


build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: ./gradlew assemble
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: deepl-java/build/



# Test and `gradlew publish` stage are disabled for now. Code needs to be tested

#######################################################
# test_cl:
# runs-on: ${{ matrix.docker-image }}
# strategy:
# matrix:
# docker-image:
# - 'eclipse-temurin:8-focal'
# - 'openjdk:8-alpine'
# - 'eclipse-temurin:11-alpine'
# - 'eclipse-temurin:17-alpine'
# - 'eclipse-temurin:18-alpine'
# - 'eclipse-temurin:19-alpine'
# use-mock-server:
# - ''
# - 'use mock server'
# env:
# DEEPL_SERVER_URL: http://deepl-mock:3000
# DEEPL_MOCK_SERVER_PORT: 3000
# DEEPL_PROXY_URL: http://deepl-mock:3001
# DEEPL_MOCK_PROXY_SERVER_PORT: 3001
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Start mock server
# if: ${{ matrix.use-mock-server == 'use mock server' }}
# run: docker run --name deepl-mock -d -p 3000:3000 deepl-mock
# - name: Start mock proxy server
# if: ${{ matrix.use-mock-server == 'use mock server' }}
# run: docker run --name deepl-mock-proxy -d -p 3001:3001 deepl-mock-proxy
# - name: Test
# run: |
# if [[ ! -z "${{ matrix.use-mock-server }}" ]]; then
# echo "Using mock server"
# export DEEPL_SERVER_URL=http://deepl-mock:3000
# export DEEPL_MOCK_SERVER_PORT=3000
# export DEEPL_PROXY_URL=http://deepl-mock:3001
# export DEEPL_MOCK_PROXY_SERVER_PORT=3001
# fi
# ./gradlew test
# - name: Stop mock proxy server
# if: ${{ matrix.use-mock-server == 'use mock server' }}
# run: docker stop deepl-mock-proxy
# - name: Stop mock server
# if: ${{ matrix.use-mock-server == 'use mock server' }}
# run: docker stop deepl-mock
# - name: Upload test results
# uses: actions/upload-artifact@v4
# with:
# name: test-results
# path: deepl-java/build/reports/tests/test

# test_examples:
# runs-on: ${{ matrix.docker-image }}
# strategy:
# matrix:
# docker-image:
# - 'maven:3.9'
# - 'maven:3.8-openjdk-18-slim'
# - 'maven:3.8-openjdk-8-slim'
# - 'maven:3.9-sapmachine-17'
# - 'maven:3.9-eclipse-temurin-8'
# - 'maven:3.9-eclipse-temurin-21'
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Test examples
# run: |
# cd examples/maven/deepl-test-app
# mvn install -B -PbuildProject -l mvn_build.log
# mvn verify -PrunIntegrationTests
# - name: Upload test results
# uses: actions/upload-artifact@v4
# with:
# name: test-results
# path: examples/maven/deepl-test-app/mvn_build.log

# publish:
# runs-on: ubuntu-latest
# needs: [ build ]
# if: startsWith(github.ref, 'refs/tags/v')
# steps:
# - name: Checkout
# uses: actions/checkout@v2
# - name: Publish
# run: ./gradlew publish
Loading