Skip to content

Commit 6a50081

Browse files
committed
ci: Add base GitHub CI
1 parent 464fafe commit 6a50081

File tree

3 files changed

+143
-0
lines changed

3 files changed

+143
-0
lines changed

.github/workflows/run_ci.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Ruby CI
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
schedule:
9+
- cron: '10 0 * * *'
10+
11+
env:
12+
SECRET_DETECTION_JSON_REPORT_FILE: "gitleaks.json"
13+
14+
jobs:
15+
package:
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
ruby_version: ['2.7', '3.2', '3.3']
20+
steps:
21+
- uses: actions/checkout@v4
22+
- name: Set up Ruby
23+
uses: ruby/setup-ruby@v1
24+
with:
25+
ruby-version: ${{ matrix.ruby_version }}
26+
bundler-cache: true
27+
- name: Build package
28+
run: bundle exec rake build
29+
- name: Upload Artifacts
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: pkg-${{ matrix.ruby_version }}
33+
path: pkg/
34+
35+
rubocop:
36+
runs-on: ubuntu-latest
37+
strategy:
38+
matrix:
39+
ruby_version: ['2.7', '3.2', '3.3']
40+
steps:
41+
- uses: actions/checkout@v4
42+
- name: Set up Ruby
43+
uses: ruby/setup-ruby@v1
44+
with:
45+
ruby-version: ${{ matrix.ruby_version }}
46+
bundler-cache: true
47+
- name: Run rubocop
48+
run: bundle exec rubocop
49+
50+
secret_detection:
51+
runs-on: ubuntu-latest
52+
steps:
53+
- name: Checkout
54+
uses: actions/checkout@v4
55+
with:
56+
fetch-depth: 0
57+
- name: Install and run secret detection
58+
run: |
59+
wget https://github.com/gitleaks/gitleaks/releases/download/v8.19.3/gitleaks_8.19.3_linux_x64.tar.gz
60+
tar -xzf gitleaks_8.19.3_linux_x64.tar.gz
61+
EXITCODE=0
62+
./gitleaks detect -r ${SECRET_DETECTION_JSON_REPORT_FILE} --source . --log-opts="--all --full-history" || EXITCODE=$?
63+
if [[ $EXITCODE -ne 0 ]]; then
64+
exit $EXITCODE
65+
fi
66+
- name: Upload secret detection artifact
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: secret-detection-results
70+
path: gitleaks.json
71+
72+
license_check:
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: Checkout
76+
uses: actions/checkout@v4
77+
- name: Run license check
78+
run: |
79+
./license_checker.sh '*.rb' | tee license_check_output.txt
80+
[ ! -s license_check_output.txt ]
81+
82+
83+
# Test and gem publishing stage are disabled/missing for now. Code needs to be tested
84+
85+
#######################################################
86+
# test:
87+
# runs-on: ubuntu-latest
88+
# strategy:
89+
# matrix:
90+
# include:
91+
# - ruby_version: '2.7'
92+
# use_mock_server: ''
93+
# - ruby_version: '3.2'
94+
# use_mock_server: ''
95+
# - ruby_version: '3.3'
96+
# use_mock_server: ''
97+
# - ruby_version: '2.7'
98+
# use_mock_server: 'use mock server'
99+
# - ruby_version: '3.2'
100+
# use_mock_server: 'use mock server'
101+
# - ruby_version: '3.3'
102+
# use_mock_server: 'use mock server'
103+
# steps:
104+
# - uses: actions/checkout@v4
105+
# - name: Set up Ruby
106+
# uses: ruby/setup-ruby@v1
107+
# with:
108+
# ruby-version: ${{ matrix.ruby_version }}
109+
# bundler-cache: true
110+
# - name: Configure Mock Server
111+
# if: matrix.use_mock_server != ''
112+
# run: |
113+
# echo "Using mock server"
114+
# export DEEPL_SERVER_URL=http://deepl-mock:3000
115+
# export DEEPL_MOCK_SERVER_PORT=3000
116+
# export DEEPL_PROXY_URL=http://deepl-mock:3001
117+
# export DEEPL_MOCK_PROXY_SERVER_PORT=3001
118+
# - name: Run Tests
119+
# run: bundle exec rake test
120+
# - name: Run RSpec Tests
121+
# run: bundle exec rspec --format RspecJunitFormatter --out rspec.xml
122+
# - name: Upload Test Results
123+
# uses: actions/upload-artifact@v4
124+
# with:
125+
# name: test-results
126+
# path: rspec.xml

.gitleaksignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
0d52c9d0bd4a3ba8658082dc423b75eaef19df4b:spec/api/configuration_spec.rb:generic-api-key:60
2+
fc068fd7b86172928f9dd9084aca4c441f996880:spec/api/configuration_spec.rb:generic-api-key:60
3+
f71cdb11f9fe277fcfe90e8e694a52a27e2a5274:spec/api/configuration_spec.rb:generic-api-key:60
4+
af659c126c3deaa4129f3816174c69ba542e8e61:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:45
5+
8cc9017bcce8fd0e56638eafdc91caff8faca8fe:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:45
6+
fe1ca256e85c762b1a66007cd801dc92a7e2623c:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:45
7+
e8b2673d7c0065d4d6b2a331145f752f159d5165:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:45
8+
52c689005c97eb908cfdac19a181e01289bfae7e:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:45
9+
af659c126c3deaa4129f3816174c69ba542e8e61:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:52
10+
e8b2673d7c0065d4d6b2a331145f752f159d5165:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:52
11+
8cc9017bcce8fd0e56638eafdc91caff8faca8fe:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:52
12+
fe1ca256e85c762b1a66007cd801dc92a7e2623c:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:52
13+
52c689005c97eb908cfdac19a181e01289bfae7e:spec/fixtures/vcr_cassettes/deepl_document.yml:generic-api-key:52

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,10 @@ To run tests (rspec and rubocop), use
411411
bundle exec rake test
412412
```
413413

414+
### Caution: Gitleaks and VCR tests
415+
416+
When contributing to the library, in the CI `gitleaks` might pick up document keys (from the document translation workflow) or example API keys as leaked secrets. To fix this you can add them to the `.gitleaksignore` file, please see the [documentation](https://github.com/gitleaks/gitleaks?tab=readme-ov-file#gitleaksignore) for more details.
417+
414418
### Caution: Changing VCR Tests
415419

416420
If you need to rerecord some of the VCR tests, simply setting `record: :new_episodes` and rerunning `rspec` won't be enough in some cases, specifically around document translation (due to its statefulness) and glossaries (since a glossary ID is associated with a specific API account).

0 commit comments

Comments
 (0)