|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "main" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "main" ] |
| 8 | + schedule: |
| 9 | + - cron: '40 0 * * *' |
| 10 | + |
| 11 | +env: |
| 12 | + COMPOSER_HOME: /.composer |
| 13 | + SECRET_DETECTION_JSON_REPORT_FILE: "gitleaks.json" |
| 14 | + |
| 15 | +jobs: |
| 16 | + # TODO: Enable building and testing the library against different PHP versions in GitHub |
| 17 | + # Both for `build_image` and `code_sniffer` |
| 18 | + # build_image: |
| 19 | + # runs-on: ubuntu-latest |
| 20 | + # strategy: |
| 21 | + # matrix: |
| 22 | + # php-version: |
| 23 | + # - 7.3-alpine |
| 24 | + # - 7.4-alpine |
| 25 | + # - 8.0-alpine |
| 26 | + # - 8.1-alpine |
| 27 | + # steps: |
| 28 | + # - name: Login to Docker Hub |
| 29 | + # uses: docker/login-action@v3 |
| 30 | + # with: |
| 31 | + # username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 32 | + # password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 33 | + # - name: Build Docker image |
| 34 | + # uses: docker/build-push-action@v6 |
| 35 | + # with: |
| 36 | + # context: . |
| 37 | + # file: ./Dockerfile |
| 38 | + # push: true |
| 39 | + # tags: deepl-php-${{ matrix.php-version }}:latest |
| 40 | + |
| 41 | + code_sniffer: |
| 42 | + # strategy: |
| 43 | + # matrix: |
| 44 | + # php-version: |
| 45 | + # - '7.3-alpine' |
| 46 | + # - '7.4-alpine' |
| 47 | + # - '8.0-alpine' |
| 48 | + # - '8.1-alpine' |
| 49 | + # runs-on: deepl-php-${{ matrix.php-version }} |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - name: Install PHP |
| 53 | + run: sudo apt-get update && sudo apt-get install php composer |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v4 |
| 56 | + - name: Install dependencies |
| 57 | + run: composer install |
| 58 | + - name: Code sniffer check |
| 59 | + run: vendor/bin/phpcs |
| 60 | + |
| 61 | + license_check: |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v4 |
| 66 | + - name: License check |
| 67 | + run: | |
| 68 | + ./license_checker.sh '*.php' | tee license_check_output.txt |
| 69 | + [ ! -s license_check_output.txt ] |
| 70 | +
|
| 71 | + secret_detection: |
| 72 | + runs-on: ubuntu-latest |
| 73 | + steps: |
| 74 | + - name: Checkout |
| 75 | + uses: actions/checkout@v4 |
| 76 | + with: |
| 77 | + fetch-depth: 0 |
| 78 | + - name: Install and run secret detection |
| 79 | + run: | |
| 80 | + wget https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz |
| 81 | + tar -xzf gitleaks_8.18.4_linux_x64.tar.gz |
| 82 | + EXITCODE=0 |
| 83 | + ./gitleaks detect -r ${SECRET_DETECTION_JSON_REPORT_FILE} --source . --log-opts="--all --full-history" || EXITCODE=$? |
| 84 | + if [[ $EXITCODE -ne 0 ]]; then |
| 85 | + exit $EXITCODE |
| 86 | + fi |
| 87 | + - name: Upload secret detection artifact |
| 88 | + uses: actions/upload-artifact@v4 |
| 89 | + with: |
| 90 | + name: secret-detection-results |
| 91 | + path: gitleaks.json |
| 92 | + |
| 93 | +# Test stage is disabled for now. Code needs to be tested |
| 94 | + |
| 95 | +####################################################### |
| 96 | +# test: |
| 97 | +# strategy: |
| 98 | +# matrix: |
| 99 | +# php-version: |
| 100 | +# - '7.3-alpine' |
| 101 | +# - '7.4-alpine' |
| 102 | +# - '8.0-alpine' |
| 103 | +# - '8.1-alpine' |
| 104 | +# use-mock-server: |
| 105 | +# - '' |
| 106 | +# - 'use mock server' |
| 107 | +# runs-on: deepl-php-${{ matrix.php-version }} |
| 108 | +# env: |
| 109 | +# DEEPL_SERVER_URL: http://deepl-mock:3000 |
| 110 | +# DEEPL_MOCK_SERVER_PORT: 3000 |
| 111 | +# DEEPL_PROXY_URL: http://deepl-mock:3001 |
| 112 | +# DEEPL_MOCK_PROXY_SERVER_PORT: 3001 |
| 113 | +# steps: |
| 114 | +# - name: Checkout |
| 115 | +# uses: actions/checkout@v4 |
| 116 | +# - name: Test |
| 117 | +# run: | |
| 118 | +# if [[ ! -z "${{ matrix.use-mock-server }}" ]]; then |
| 119 | +# echo "Using mock server" |
| 120 | +# export DEEPL_SERVER_URL=http://deepl-mock:3000 |
| 121 | +# export DEEPL_MOCK_SERVER_PORT=3000 |
| 122 | +# export DEEPL_PROXY_URL=http://deepl-mock:3001 |
| 123 | +# export DEEPL_MOCK_PROXY_SERVER_PORT=3001 |
| 124 | +# fi |
| 125 | +# vendor/bin/phpunit |
| 126 | +# - name: Upload test results |
| 127 | +# uses: actions/upload-artifact@v4 |
| 128 | +# with: |
| 129 | +# name: test-results |
| 130 | +# path: | |
| 131 | +# reports/cobertura.xml |
| 132 | +# reports/junit.xml |
0 commit comments