Skip to content

Commit

Permalink
Merge pull request #258 from DataDog/tonycthsu/github-test
Browse files Browse the repository at this point in the history
[SDTEST-1266] Add Github Actions tests
  • Loading branch information
anmarchenko authored Nov 27, 2024
2 parents e15f77a + 4869475 commit 6ffe55c
Show file tree
Hide file tree
Showing 12 changed files with 482 additions and 191 deletions.
158 changes: 0 additions & 158 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,13 @@ test_containers:
description: Resource class to use
type: string
default: medium
edge:
description: Use latest version of dependencies during testing
type: boolean
default: false
resource_class: <<parameters.resource_class_to_use>>
- &container_base_environment
BUNDLE_GEMFILE: /app/Gemfile
# Faster JVM startup: https://github.com/jruby/jruby/wiki/Improving-startup-time#use-the---dev-flag
JRUBY_OPTS: --dev
- &container_parameters_environment
- *container_base_environment
- COVERAGE_BASE_DIR: coverage
- &container_base
image: <<parameters.image>>
environment: *container_parameters_environment
Expand Down Expand Up @@ -76,14 +71,6 @@ step_bundle_install: &step_bundle_install
else
echo "All required gems were found in cache."
fi
step_lint: &step_lint
run:
name: Lint with standardrb
# There's no straightforward way to get the number of available processors & CPU threads in CircleCI.
# Currently it always return 18 physical processors and 36 threads, regardless of executor size.
# The workaround is to use `cpu.shares / 1024`:
# https://discuss.circleci.com/t/environment-variable-set-to-the-number-of-available-cpus/32670/4
command: PARALLEL_PROCESSOR_COUNT=$((`cat /sys/fs/cgroup/cpu/cpu.shares` / 1024)) bundle exec standardrb
step_appraisal_install: &step_appraisal_install
run:
name: Install Appraisal gems
Expand Down Expand Up @@ -137,8 +124,6 @@ filters_only_release_tags: &filters_only_release_tags

orbs:
orb:
orbs:
codecov: codecov/[email protected]
jobs:
build:
<<: *test_job_default
Expand All @@ -156,17 +141,6 @@ orbs:
- bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<<parameters.ruby_version>>-{{ checksum "lib/datadog/ci/version.rb" }}
- *check_exact_bundle_cache_hit
- *step_bundle_install
- when:
condition:
equal: [<< parameters.edge >>, true]
steps:
- *step_appraisal_update # Run on latest version of all gems we integrate with
- when:
condition:
not:
equal: [<< parameters.edge >>, true]
steps:
- *step_appraisal_install # Run on a stable set of gems we integrate with
- *save_bundle_checksum
- save_cache:
key: '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<<parameters.ruby_version>>-{{ .Environment.CIRCLE_SHA1 }}'
Expand All @@ -188,50 +162,9 @@ orbs:
- restore_cache:
keys:
- bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<<parameters.ruby_version>>-{{ checksum "lib/datadog/ci/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }}
- run:
name: Set coverage report directory
command: |
# Create a unique coverage directory for this job, to avoid conflicts when merging all results
echo 'export COVERAGE_DIR="$COVERAGE_BASE_DIR/versions/$CIRCLE_JOB/$CIRCLE_NODE_INDEX"' >> $BASH_ENV
- *step_run_all_tests
- store_test_results:
path: /tmp/rspec
- persist_to_workspace:
root: .
paths:
- coverage
lint:
<<: *test_job_default
steps:
- restore_cache:
keys:
- '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<<parameters.ruby_version>>-{{ .Environment.CIRCLE_SHA1 }}'
- restore_cache:
keys:
- bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<<parameters.ruby_version>>-{{ checksum "lib/datadog/ci/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }}
- *step_lint
coverage:
<<: *test_job_default
steps:
- restore_cache:
keys:
- '{{ .Environment.CIRCLE_CACHE_VERSION }}-bundled-repo-<<parameters.ruby_version>>-{{ .Environment.CIRCLE_SHA1 }}'
- restore_cache:
keys:
- bundle-{{ .Environment.CIRCLE_CACHE_VERSION }}-{{ checksum ".circleci/images/primary/binary_version" }}-<<parameters.ruby_version>>-{{ checksum "lib/datadog/ci/version.rb" }}-{{ .Branch }}-{{ checksum ".circleci/bundle_checksum" }}
- attach_workspace:
at: /tmp/workspace
- run:
name: Generate combined coverage report for all tests
command: COVERAGE_DIR=/tmp/workspace/coverage bundle exec rake coverage:report
- codecov/upload:
file: /tmp/workspace/coverage/report/coverage.xml
- run:
name: Generate individual coverage report for each Ruby version
command: COVERAGE_DIR=/tmp/workspace/coverage bundle exec rake coverage:report_per_ruby_version
- store_artifacts:
path: /tmp/workspace/coverage/report/
destination: coverage
commands:
docker-wait:
description: Wait for containers to listen on a TCP port.
Expand Down Expand Up @@ -297,95 +230,10 @@ job_configuration:
workflows:
version: 2
build-and-test:
jobs:
- orb/lint:
<<: *config-3_3-small
name: lint
requires:
- build-3.2
- orb/coverage:
<<: *config-3_3-small
name: coverage
requires:
- test-2.7
- test-3.0
- test-3.1
- test-3.2
- test-3.3
- test-3.4
# ADD NEW RUBIES HERE
- test-jruby-9.4
- orb/build:
<<: *config-2_7
name: build-2.7
- orb/test:
<<: *config-2_7
name: test-2.7
requires:
- build-2.7
- orb/build:
<<: *config-3_0
name: build-3.0
- orb/test:
<<: *config-3_0
name: test-3.0
requires:
- build-3.0
- orb/build:
<<: *config-3_1
name: build-3.1
- orb/test:
<<: *config-3_1
name: test-3.1
requires:
- build-3.1
- orb/build:
<<: *config-3_2
name: build-3.2
- orb/test:
<<: *config-3_2
name: test-3.2
requires:
- build-3.2
- orb/build:
<<: *config-3_3
name: build-3.3
- orb/test:
<<: *config-3_3
name: test-3.3
requires:
- build-3.3
- orb/build:
<<: *config-3_4
name: build-3.4
- orb/test:
<<: *config-3_4
name: test-3.4
requires:
- build-3.4
# ADD NEW RUBIES HERE
- orb/build:
<<: *config-jruby-9_4
name: build-jruby-9.4
- orb/test:
<<: *config-jruby-9_4
name: test-jruby-9.4
requires:
- build-jruby-9.4
# This workflow runs the same `build` and `test` jobs as above on a schedule.
edge:
triggers:
- schedule:
cron: '0 0 * * 1-5' # Every weekday
filters:
branches:
only:
- main
jobs:
- orb/build:
<<: *config-2_7
name: build-2.7
edge: true
- orb/test:
<<: *config-2_7
name: test-2.7
Expand All @@ -394,7 +242,6 @@ workflows:
- orb/build:
<<: *config-3_0
name: build-3.0
edge: true
- orb/test:
<<: *config-3_0
name: test-3.0
Expand All @@ -403,7 +250,6 @@ workflows:
- orb/build:
<<: *config-3_1
name: build-3.1
edge: true
- orb/test:
<<: *config-3_1
name: test-3.1
Expand All @@ -412,7 +258,6 @@ workflows:
- orb/build:
<<: *config-3_2
name: build-3.2
edge: true
- orb/test:
<<: *config-3_2
name: test-3.2
Expand All @@ -421,7 +266,6 @@ workflows:
- orb/build:
<<: *config-3_3
name: build-3.3
edge: true
- orb/test:
<<: *config-3_3
name: test-3.3
Expand All @@ -430,7 +274,6 @@ workflows:
- orb/build:
<<: *config-3_4
name: build-3.4
edge: true
- orb/test:
<<: *config-3_4
name: test-3.4
Expand All @@ -440,7 +283,6 @@ workflows:
- orb/build:
<<: *config-jruby-9_4
name: build-jruby-9.4
edge: true
- orb/test:
<<: *config-jruby-9_4
name: test-jruby-9.4
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,20 @@ on:
# The branches below must be a subset of the branches above
branches: [main]
jobs:
check:
name: Check types
lint:
name: Lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Install dependencies
run: bundle install
- run: bundle exec standardrb

typecheck:
name: Type checking
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
Expand Down
Loading

0 comments on commit 6ffe55c

Please sign in to comment.