diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e9bf6210d..4ef7f7ac13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ jobs: - run: bundle - run: rubocop + unit_tests: needs: run_rubocop runs-on: ubuntu-22.04 @@ -30,7 +31,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: [2.2.10, 3.2.0, jruby-9.3.9.0] + ruby-version: [2.2.10, 3.2.0] steps: - name: Configure git run: 'git config --global init.defaultBranch main' @@ -58,13 +59,14 @@ jobs: }, "3.2.0": { "rails": "norails,rails61,rails70" - }, - "jruby-9.3.9.0": { - "rails": "norails,rails61" } } - - if: matrix.ruby-version == '2.2.10' || matrix.ruby-version == 'jruby-9.3.9.0' + - if: matrix.ruby-version == '2.2.10' + name: Prepare mysql dirextory + run: sudo chown -R $USER /usr/local + + - if: matrix.ruby-version == '2.2.10' name: Cache mysql55 id: mysql55-cache uses: actions/cache@v3.2.2 @@ -72,7 +74,7 @@ jobs: path: /usr/local/mysql55 key: mysql55-install - - if: steps.mysql55-cache.outputs.cache-hit != 'true' && (matrix.ruby-version == '2.2.10' || matrix.ruby-version == 'jruby-9.3.9.0') + - if: steps.mysql55-cache.outputs.cache-hit != 'true' && matrix.ruby-version == '2.2.10' name: Install mysql55 run: sudo ./test/script/install_mysql55 @@ -81,6 +83,7 @@ jobs: env: RUBY_VERSION: ${{ matrix.ruby-version }} RAILS_VERSION: ${{ env.rails }} + - name: Run Unit Tests uses: nick-fields/retry@v2.8.2 with: @@ -98,6 +101,7 @@ jobs: name: coverage-report-unit-tests path: lib/coverage_*/.resultset.json + multiverse: needs: run_rubocop runs-on: ubuntu-22.04 @@ -197,7 +201,12 @@ jobs: with: ruby-version: ${{ matrix.ruby-version }} - - if: matrix.ruby-version == '2.2.10' || matrix.ruby-version == '2.3.8' + # This allows the cache in the following step to be able to write files to the directory needed for mysql + - if: matrix.ruby-version == '2.2.10' + name: Prepare mysql directory + run: sudo chown -R $USER /usr/local + + - if: matrix.ruby-version == '2.2.10' name: Cache mysql55 id: mysql55-cache uses: actions/cache@v3.2.2 @@ -205,7 +214,7 @@ jobs: path: /usr/local/mysql55 key: mysql55-install - - if: steps.mysql55-cache.outputs.cache-hit != 'true' && (matrix.ruby-version == '2.2.10' || matrix.ruby-version == '2.3.8') + - if: steps.mysql55-cache.outputs.cache-hit != 'true' && matrix.ruby-version == '2.2.10' name: Install mysql55 run: sudo ./test/script/install_mysql55 @@ -245,6 +254,7 @@ jobs: path: lib/coverage_*/.resultset.json retention-days: 2 + infinite_tracing: needs: run_rubocop runs-on: ubuntu-22.04 @@ -285,137 +295,6 @@ jobs: name: coverage-report-infinite-tracing path: lib/coverage_*/.resultset.json - check_jruby_multiverse: - needs: run_rubocop - runs-on: ubuntu-22.04 - outputs: - run_job: ${{ steps.filter.outputs.run_job }} - steps: - - name: Configure git - run: 'git config --global init.defaultBranch main' - - uses: actions/checkout@v3 - - uses: dorny/paths-filter@v2 - id: filter - with: - filters: | - run_job: - - 'lib/new_relic/agent/instrumentation/**' - - jruby_multiverse: - needs: check_jruby_multiverse - if: ${{ needs.check_jruby_multiverse.outputs.run_job == 'true' }} - runs-on: ubuntu-22.04 - services: - elasticsearch7: - image: elasticsearch:7.16.2 - env: - discovery.type: single-node - ports: - - 9200:9200 - options: >- - --health-cmd "curl http://localhost:9200/_cluster/health" - --health-interval 10s - --health-timeout 5s - --health-retries 10 - elasticsearch8: - image: elasticsearch:8.4.2 - env: - discovery.type: single-node - xpack.security.enabled: false - ports: - - 9250:9200 - options: >- - --health-cmd "curl http://localhost:9200/_cluster/health" - --health-interval 10s - --health-timeout 5s - --health-retries 10 - memcached: - image: memcached:latest - ports: - - 11211:11211 - options: >- - --health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/udp/127.0.0.1/11211'" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - mongodb: - image: mongo:5.0.11 - ports: - - 27017:27017 - mysql: - image: mysql:5.7 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - ports: - - "3306:3306" - postgres: - image: postgres:latest - ports: - - 5432:5432 - rabbitmq: - image: rabbitmq:latest - ports: - - 5672:5672 - options: >- - --health-cmd "rabbitmq-diagnostics -q check_port_connectivity" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - redis: - image: redis - ports: - - 6379:6379 - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - strategy: - fail-fast: false - matrix: - multiverse: [agent, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest] - steps: - - name: Set the default Java version - run: sudo update-alternatives --set java ${JAVA_HOME_8_X64}/bin/java && - sudo update-alternatives --set javac ${JAVA_HOME_8_X64}/bin/javac && - java -version && - javac -version - - - name: Configure git - run: 'git config --global init.defaultBranch main' - - - name: Check out the source code - uses: actions/checkout@v3 - - - name: Install JRuby - uses: ruby/setup-ruby@v1 - with: - ruby-version: jruby-9.3.9.0 - env: - JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 - - - name: Bundle - run: bundle install - env: - JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 - - - name: Run Multiverse Tests - uses: nick-fields/retry@v2.8.2 - with: - timeout_minutes: 60 - max_attempts: 1 - # jruby -v yields info about which JVM version JRuby is using - command: jruby -v; bundle exec rake test:multiverse[group=${{ matrix.multiverse }},verbose] - env: - DB_PORT: ${{ job.services.mysql.ports[3306] }} - SERIALIZE: 1 - JRUBY_OPTS: --dev --debug - JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 - - - name: Annotate errors - if: ${{ failure() }} - uses: ./.github/actions/annotate simplecov: needs: [unit_tests, multiverse, infinite_tracing] diff --git a/.github/workflows/ci_cron.yml b/.github/workflows/ci_cron.yml index c27936ddcc..c3c3ebd76d 100644 --- a/.github/workflows/ci_cron.yml +++ b/.github/workflows/ci_cron.yml @@ -22,6 +22,7 @@ jobs: - run: bundle - run: rubocop + unit_tests: runs-on: ubuntu-22.04 services: @@ -35,7 +36,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: [2.2.10, 2.3.8, 2.4.10, 2.5.9, 2.6.10, 2.7.7, 3.0.5, 3.1.3, 3.2.0, jruby-9.3.9.0] + ruby-version: [2.2.10, 2.3.8, 2.4.10, 2.5.9, 2.6.10, 2.7.7, 3.0.5, 3.1.3, 3.2.0] steps: - name: Configure git @@ -85,12 +86,13 @@ jobs: }, "3.2.0": { "rails": "norails,rails61,rails70,railsedge" - }, - "jruby-9.3.9.0": { - "rails": "norails,rails61,rails60" } } + - if: matrix.ruby-version == '2.2.10' || matrix.ruby-version == '2.3.8' || matrix.ruby-version == '2.4.10' || matrix.ruby-version == '2.5.9' || matrix.ruby-version == '2.6.10' + name: Prepare mysql dirextory + run: sudo chown -R $USER /usr/local + - if: matrix.ruby-version == '2.2.10' || matrix.ruby-version == '2.3.8' || matrix.ruby-version == '2.4.10' || matrix.ruby-version == '2.5.9' || matrix.ruby-version == '2.6.10' name: Cache mysql55 id: mysql55-cache @@ -119,6 +121,7 @@ jobs: DB_PORT: ${{ job.services.mysql.ports[3306] }} JRUBY_OPTS: --dev --debug + multiverse: runs-on: ubuntu-22.04 services: @@ -216,6 +219,10 @@ jobs: with: ruby-version: ${{ matrix.ruby-version }} + - if: matrix.ruby-version == '2.2.10' || matrix.ruby-version == '2.3.8' + name: Prepare mysql dirextory + run: sudo chown -R $USER /usr/local + - if: matrix.ruby-version == '2.2.10' || matrix.ruby-version == '2.3.8' name: Cache mysql55 id: mysql55-cache @@ -256,6 +263,7 @@ jobs: if: ${{ failure() }} uses: ./.github/actions/annotate + infinite_tracing: runs-on: ubuntu-22.04 strategy: @@ -288,122 +296,10 @@ jobs: if: ${{ failure() }} uses: ./.github/actions/annotate - jruby_multiverse: - runs-on: ubuntu-22.04 - services: - elasticsearch7: - image: elasticsearch:7.16.2 - env: - discovery.type: single-node - ports: - - 9200:9200 - options: >- - --health-cmd "curl http://localhost:9200/_cluster/health" - --health-interval 10s - --health-timeout 5s - --health-retries 10 - elasticsearch8: - image: elasticsearch:8.4.2 - env: - discovery.type: single-node - xpack.security.enabled: false - ports: - - 9250:9200 - options: >- - --health-cmd "curl http://localhost:9200/_cluster/health" - --health-interval 10s - --health-timeout 5s - --health-retries 10 - memcached: - image: memcached:latest - ports: - - 11211:11211 - options: >- - --health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/udp/127.0.0.1/11211'" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - mongodb: - image: mongo:5.0.11 - ports: - - 27017:27017 - mysql: - image: mysql:5.7 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - ports: - - "3306:3306" - postgres: - image: postgres:latest - ports: - - 5432:5432 - rabbitmq: - image: rabbitmq:latest - ports: - - 5672:5672 - options: >- - --health-cmd "rabbitmq-diagnostics -q check_port_connectivity" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - redis: - image: redis - ports: - - 6379:6379 - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - strategy: - fail-fast: false - matrix: - multiverse: [agent, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest] - steps: - - name: Set the default Java version - run: sudo update-alternatives --set java ${JAVA_HOME_8_X64}/bin/java && - sudo update-alternatives --set javac ${JAVA_HOME_8_X64}/bin/javac && - java -version && - javac -version - - - name: Configure git - run: 'git config --global init.defaultBranch main' - - - name: Check out the source code - uses: actions/checkout@v3 - - - name: Install JRuby - uses: ruby/setup-ruby@v1 - with: - ruby-version: jruby-9.3.9.0 - env: - JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 - - - name: Bundle - run: bundle install - env: - JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 - - - name: Run Multiverse Tests - uses: nick-fields/retry@v2.8.2 - with: - timeout_minutes: 60 - max_attempts: 2 - command: jruby -v; bundle exec rake test:multiverse[group=${{ matrix.multiverse }},verbose] - env: - DB_PORT: ${{ job.services.mysql.ports[3306] }} - SERIALIZE: 1 - JRUBY_OPTS: --dev --debug - JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 - - - name: Annotate errors - if: ${{ failure() }} - uses: ./.github/actions/annotate notify_slack_fail: name: Notify slack fail - needs: [unit_tests, multiverse, infinite_tracing, jruby_multiverse] + needs: [unit_tests, multiverse, infinite_tracing] runs-on: ubuntu-22.04 if: always() steps: @@ -417,9 +313,10 @@ jobs: status: FAILED color: danger + notify_slack_success: name: Notify slack success - needs: [unit_tests, multiverse, infinite_tracing, jruby_multiverse] + needs: [unit_tests, multiverse, infinite_tracing] runs-on: ubuntu-22.04 if: always() steps: diff --git a/.github/workflows/ci_jruby.yml b/.github/workflows/ci_jruby.yml new file mode 100644 index 0000000000..866b3d8029 --- /dev/null +++ b/.github/workflows/ci_jruby.yml @@ -0,0 +1,160 @@ +name: JRuby Continuous Integration + +on: + schedule: + - cron: '0 9 * * *' + workflow_dispatch: + +jobs: + unit_tests: + runs-on: ubuntu-22.04 + services: + mysql: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + ports: + - "3306:3306" + strategy: + fail-fast: false + steps: + - name: Configure git + run: 'git config --global init.defaultBranch main' + - uses: actions/checkout@v3 + + # - curl is needed for Curb + # - xslt is needed for older Nokogiris, RUBY_VERSION < 2.5 + # - sasl is needed for memcached + - name: Install OS packages + run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libcurl4-nss-dev libsasl2-dev + + - name: Install Ruby jruby-9.3.9.0 + uses: ruby/setup-ruby@v1 + with: + ruby-version: jruby-9.3.9.0 + + - name: Bundle + run: bundle install + + - name: Run Unit Tests + uses: nick-fields/retry@v2.8.2 + with: + timeout_minutes: 30 + max_attempts: 2 + command: bundle exec rake test:env[norails,rails61,rails60] TESTOPTS="--verbose" + env: + DB_PORT: ${{ job.services.mysql.ports[3306] }} + JRUBY_OPTS: --dev --debug + + + jruby_multiverse: + runs-on: ubuntu-22.04 + services: + elasticsearch7: + image: elasticsearch:7.16.2 + env: + discovery.type: single-node + ports: + - 9200:9200 + options: >- + --health-cmd "curl http://localhost:9200/_cluster/health" + --health-interval 10s + --health-timeout 5s + --health-retries 10 + elasticsearch8: + image: elasticsearch:8.4.2 + env: + discovery.type: single-node + xpack.security.enabled: false + ports: + - 9250:9200 + options: >- + --health-cmd "curl http://localhost:9200/_cluster/health" + --health-interval 10s + --health-timeout 5s + --health-retries 10 + memcached: + image: memcached:latest + ports: + - 11211:11211 + options: >- + --health-cmd "timeout 5 bash -c 'cat < /dev/null > /dev/udp/127.0.0.1/11211'" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + mongodb: + image: mongo:5.0.11 + ports: + - 27017:27017 + mysql: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + ports: + - "3306:3306" + postgres: + image: postgres:latest + ports: + - 5432:5432 + rabbitmq: + image: rabbitmq:latest + ports: + - 5672:5672 + options: >- + --health-cmd "rabbitmq-diagnostics -q check_port_connectivity" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + redis: + image: redis + ports: + - 6379:6379 + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 + strategy: + fail-fast: false + matrix: + multiverse: [agent, background, background_2, database, frameworks, httpclients, httpclients_2, rails, rest] + steps: + - name: Set the default Java version + run: sudo update-alternatives --set java ${JAVA_HOME_8_X64}/bin/java && + sudo update-alternatives --set javac ${JAVA_HOME_8_X64}/bin/javac && + java -version && + javac -version + + - name: Configure git + run: 'git config --global init.defaultBranch main' + + - name: Check out the source code + uses: actions/checkout@v3 + + - name: Install JRuby + uses: ruby/setup-ruby@v1 + with: + ruby-version: jruby-9.3.9.0 + env: + JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 + + - name: Bundle + run: bundle install + env: + JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 + + - name: Run Multiverse Tests + run: ./.github/workflows/scripts/retry_command + env: + TEST_CMD: "bundle exec rake test:multiverse[group=${{ matrix.multiverse }},verbose]" + RETRY_ATTEMPS: 2 + SERIALIZE: 1 + DB_PORT: ${{ job.services.mysql.ports[3306] }} + JRUBY_OPTS: --dev --debug + JAVA_HOME: /usr/lib/jvm/temurin-8-jdk-amd64 + + - name: Annotate errors + if: ${{ failure() }} + uses: ./.github/actions/annotate diff --git a/.github/workflows/scripts/retry_command b/.github/workflows/scripts/retry_command new file mode 100755 index 0000000000..bce91b10f9 --- /dev/null +++ b/.github/workflows/scripts/retry_command @@ -0,0 +1,15 @@ +#!/bin/bash + +# RETRY_ATTEMPTS +# TEST_CMD + +count=0 +return_val=1 + +while [[ $return_val != 0 && $count -le $RETRY_ATTEMPTS ]]; do + $TEST_CMD + return_val=$? + count+=1 +done + +exit $return_val \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index 201f277524..2c8d6d858d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,7 +14,135 @@ AllCops: Exclude: - 'test/multiverse/suites/active_record/db/schema.rb' - 'test/multiverse/suites/active_record_pg/db/schema.rb' - NewCops: enable + +# New cops +Layout/LineContinuationLeadingSpace: # new in 1.31 + Enabled: true +Layout/LineContinuationSpacing: # new in 1.31 + Enabled: true +Lint/ConstantOverwrittenInRescue: # new in 1.31 + Enabled: true +Lint/DuplicateMagicComment: # new in 1.37 + Enabled: true +Lint/NonAtomicFileOperation: # new in 1.31 + Enabled: true +Lint/RefinementImportMethods: # new in 1.27 + Enabled: true +Lint/RequireRangeParentheses: # new in 1.32 + Enabled: true +Lint/UselessRuby2Keywords: # new in 1.23 + Enabled: true +Naming/BlockForwarding: # new in 1.24 + Enabled: true +Security/CompoundHash: # new in 1.28 + Enabled: true +Style/ArrayIntersect: # new in 1.40 + Enabled: true +Style/EmptyHeredoc: # new in 1.32 + Enabled: true +Style/FileRead: # new in 1.24 + Enabled: true +Style/FileWrite: # new in 1.24 + Enabled: true +Style/MagicCommentFormat: # new in 1.35 + Enabled: true +Style/MapCompactWithConditionalBlock: # new in 1.30 + Enabled: true +Style/MapToSet: # new in 1.42 + Enabled: true +Style/MinMaxComparison: # new in 1.42 + Enabled: true +Style/NestedFileDirname: # new in 1.26 + Enabled: true +Style/ObjectThen: # new in 1.28 + Enabled: true +Style/OperatorMethodCall: # new in 1.37 + Enabled: true +Style/RedundantConstantBase: # new in 1.40 + Enabled: true +Style/RedundantDoubleSplatHashBraces: # new in 1.41 + Enabled: true +Style/RedundantEach: # new in 1.38 + Enabled: true +Style/RedundantInitialize: # new in 1.27 + Enabled: true +Style/RedundantStringEscape: # new in 1.37 + Enabled: true +Style/YodaExpression: # new in 1.42 + Enabled: true +Minitest/AssertKindOf: # new in 0.10 + Enabled: true +Minitest/AssertOutput: # new in 0.10 + Enabled: true +Minitest/AssertPathExists: # new in 0.10 + Enabled: true +Minitest/AssertPredicate: # new in 0.18 + Enabled: true +Minitest/AssertRaisesCompoundBody: # new in 0.21 + Enabled: true +Minitest/AssertRaisesWithRegexpArgument: # new in 0.22 + Enabled: true +Minitest/AssertSilent: # new in 0.10 + Enabled: true +Minitest/AssertWithExpectedArgument: # new in 0.11 + Enabled: true +Minitest/AssertionInLifecycleHook: # new in 0.10 + Enabled: true +Minitest/DuplicateTestRun: # new in 0.19 + Enabled: true +Minitest/EmptyLineBeforeAssertionMethods: # new in 0.23 + Enabled: true +Minitest/LiteralAsActualArgument: # new in 0.10 + Enabled: true +Minitest/MultipleAssertions: # new in 0.10 + Enabled: true +Minitest/RefuteInDelta: # new in 0.10 + Enabled: true +Minitest/RefuteKindOf: # new in 0.10 + Enabled: true +Minitest/RefutePathExists: # new in 0.10 + Enabled: true +Minitest/SkipEnsure: # new in 0.20 + Enabled: true +Minitest/SkipWithoutReason: # new in 0.24 + Enabled: true +Minitest/UnreachableAssertion: # new in 0.14 + Enabled: true +Minitest/UnspecifiedException: # new in 0.10 + Enabled: true +Performance/AncestorsInclude: # new in 1.7 + Enabled: true +Performance/BigDecimalWithNumericArgument: # new in 1.7 + Enabled: true +Performance/BlockGivenWithExplicitBlock: # new in 1.9 + Enabled: true +Performance/CollectionLiteralInLoop: # new in 1.8 + Enabled: true +Performance/ConcurrentMonotonicTime: # new in 1.12 + Enabled: true +Performance/ConstantRegexp: # new in 1.9 + Enabled: true +Performance/RedundantEqualityComparisonBlock: # new in 1.10 + Enabled: true +Performance/RedundantSortBlock: # new in 1.7 + Enabled: true +Performance/RedundantSplitRegexpArgument: # new in 1.10 + Enabled: true +Performance/RedundantStringChars: # new in 1.7 + Enabled: true +Performance/ReverseFirst: # new in 1.7 + Enabled: true +Performance/SortReverse: # new in 1.7 + Enabled: true +Performance/Squeeze: # new in 1.7 + Enabled: true +Performance/StringIdentifierArgument: # new in 1.13 + Enabled: true +Performance/StringInclude: # new in 1.7 + Enabled: true + + +# Old cops Bundler/DuplicatedGem: Enabled: true