diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..e7ba7782e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: Reusable action of building snapshot and publish + +on: + workflow_call: + inputs: + action: + required: true + type: string + travis_tag: + required: true + type: string + secrets: + MAVEN_SIGNING_KEY_BASE64: + required: true + MAVEN_SIGNING_PASSPHRASE: + required: true + MAVEN_CENTRAL_USERNAME: + required: true + MAVEN_CENTRAL_PASSWORD: + required: true +jobs: + run_build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: set up JDK 8 + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'temurin' + cache: gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: ${{ inputs.action }} + env: + MAVEN_SIGNING_KEY_BASE64: ${{ secrets.MAVEN_SIGNING_KEY_BASE64 }} + MAVEN_SIGNING_PASSPHRASE: ${{ secrets.MAVEN_SIGNING_PASSPHRASE }} + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + run: TRAVIS_TAG=${{ inputs.travis_tag }} ./gradlew ${{ inputs.action }} diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml new file mode 100644 index 000000000..e4d1c7e7d --- /dev/null +++ b/.github/workflows/integration_test.yml @@ -0,0 +1,56 @@ +name: Reusable action of running integration of production suite + +on: + workflow_call: + inputs: + FULLSTACK_TEST_REPO: + required: false + type: string + secrets: + CI_USER_TOKEN: + required: true + TRAVIS_COM_TOKEN: + required: true +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + # You should create a personal access token and store it in your repository + token: ${{ secrets.CI_USER_TOKEN }} + repository: 'optimizely/travisci-tools' + path: 'home/runner/travisci-tools' + ref: 'master' + - name: set SDK Branch if PR + if: ${{ github.event_name == 'pull_request' }} + run: | + echo "SDK_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV + echo "TRAVIS_BRANCH=${{ github.head_ref }}" >> $GITHUB_ENV + - name: set SDK Branch if not pull request + if: ${{ github.event_name != 'pull_request' }} + run: | + echo "SDK_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV + echo "TRAVIS_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV + - name: Trigger build + env: + SDK: java + FULLSTACK_TEST_REPO: ${{ inputs.FULLSTACK_TEST_REPO }} + BUILD_NUMBER: ${{ github.run_id }} + TESTAPP_BRANCH: master + GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }} + TRAVIS_EVENT_TYPE: ${{ github.event_name }} + GITHUB_CONTEXT: ${{ toJson(github) }} + TRAVIS_REPO_SLUG: ${{ github.repository }} + TRAVIS_PULL_REQUEST_SLUG: ${{ github.repository }} + UPSTREAM_REPO: ${{ github.repository }} + TRAVIS_COMMIT: ${{ github.sha }} + TRAVIS_PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }} + TRAVIS_PULL_REQUEST: ${{ github.event.pull_request.number }} + UPSTREAM_SHA: ${{ github.sha }} + TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} + EVENT_MESSAGE: ${{ github.event.message }} + HOME: 'home/runner' + run: | + echo "$GITHUB_CONTEXT" + home/runner/travisci-tools/trigger-script-with-status-update.sh diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml new file mode 100644 index 000000000..a7c2eafe9 --- /dev/null +++ b/.github/workflows/java.yml @@ -0,0 +1,116 @@ + +name: Java CI with Gradle + +on: + push: + branches: [ master ] + tags: + - '*' + pull_request: + branches: [ master ] + workflow_dispatch: + inputs: + SNAPSHOT: + type: boolean + description: Set SNAPSHOT true to publish + +jobs: + lint_markdown_files: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '2.6' + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Install gem + run: | + gem install awesome_bot + - name: Run tests + run: find . -type f -name '*.md' -exec awesome_bot {} \; + + integration_tests: + uses: optimizely/java-sdk/.github/workflows/integration_test.yml@master + secrets: + CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} + TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} + + fullstack_production_suite: + uses: optimizely/java-sdk/.github/workflows/integration_test.yml@master + with: + FULLSTACK_TEST_REPO: ProdTesting + secrets: + CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} + TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} + + test: + if: startsWith(github.ref, 'refs/tags/') != true + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + jdk: [8, 9] + optimizely_default_parser: [GSON_CONFIG_PARSER, JACKSON_CONFIG_PARSER, JSON_CONFIG_PARSER, JSON_SIMPLE_CONFIG_PARSER] + steps: + - name: checkout + uses: actions/checkout@v2 + + - name: set up JDK ${{ matrix.jdk }} + uses: AdoptOpenJDK/install-jdk@v1 + with: + version: ${{ matrix.jdk }} + architecture: x64 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Gradle cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}-${{ hashFiles('**/buildSrc/**/*.kt') }} + + - name: run tests + id: unit_tests + env: + optimizely_default_parser: ${{ matrix.optimizely_default_parser }} + run: | + ./gradlew clean + ./gradlew exhaustiveTest + ./gradlew build + - name: Check on failures + if: steps.unit_tests.outcome != 'success' + run: | + cat /home/runner/java-sdk/core-api/build/reports/findbugs/main.html + cat /home/runner/java-sdk/core-api/build/reports/findbugs/test.html + - name: Check on success + if: steps.unit_tests.outcome == 'success' + run: | + ./gradlew coveralls uploadArchives --console plain + + publish: + if: startsWith(github.ref, 'refs/tags/') + uses: optimizely/java-sdk/.github/workflows/build.yml@master + with: + action: ship + travis_tag: ${GITHUB_REF#refs/*/} + secrets: + MAVEN_SIGNING_KEY_BASE64: ${{ secrets.MAVEN_SIGNING_KEY_BASE64 }} + MAVEN_SIGNING_PASSPHRASE: ${{ secrets.MAVEN_SIGNING_PASSPHRASE }} + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + + snapshot: + if: ${{ github.event.inputs.SNAPSHOT == 'true' && github.event_name == 'workflow_dispatch' }} + uses: optimizely/java-sdk/.github/workflows/build.yml@master + with: + action: ship + travis_tag: BB-SNAPSHOT + secrets: + MAVEN_SIGNING_KEY_BASE64: ${{ secrets.MAVEN_SIGNING_KEY_BASE64 }} + MAVEN_SIGNING_PASSPHRASE: ${{ secrets.MAVEN_SIGNING_PASSPHRASE }} + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} diff --git a/.github/workflows/source_clear_cron.yml b/.github/workflows/source_clear_cron.yml new file mode 100644 index 000000000..54eca5358 --- /dev/null +++ b/.github/workflows/source_clear_cron.yml @@ -0,0 +1,16 @@ +name: Source clear + +on: + schedule: + # Runs "weekly" + - cron: '0 0 * * 0' + +jobs: + source_clear: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Source clear scan + env: + SRCCLR_API_TOKEN: ${{ secrets.SRCCLR_API_TOKEN }} + run: curl -sSL https://download.sourceclear.com/ci.sh | bash -s – scan diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2735eacaf..000000000 --- a/.travis.yml +++ /dev/null @@ -1,92 +0,0 @@ -language: java -dist: trusty -jdk: - - openjdk8 - - oraclejdk8 - - oraclejdk9 -install: true -env: - - optimizely_default_parser=GSON_CONFIG_PARSER - - optimizely_default_parser=JACKSON_CONFIG_PARSER - - optimizely_default_parser=JSON_CONFIG_PARSER - - optimizely_default_parser=JSON_SIMPLE_CONFIG_PARSER -script: - - "./gradlew clean" - - "./gradlew exhaustiveTest" - - "./gradlew build" - -cache: - gradle: true - directories: - - "$HOME/.gradle/caches" - - "$HOME/.gradle/wrapper" -branches: - only: - - master - - /^\d+\.\d+\.(\d|[x])+(-SNAPSHOT|-alpha|-beta)?\d*$/ # trigger builds on tags which are semantically versioned to ship the SDK. -after_success: - - ./gradlew coveralls uploadArchives --console plain -after_failure: - - cat /home/travis/build/optimizely/java-sdk/core-api/build/reports/findbugs/main.html - - cat /home/travis/build/optimizely/java-sdk/core-api/build/reports/findbugs/test.html - -# Integration tests need to run first to reset the PR build status to pending -stages: - - 'Source Clear' - - 'Lint markdown files' - - 'Integration tests' - - 'Full stack production tests' - - 'Test' - - 'Publish' - - 'Snapshot' - -jobs: - include: - - stage: 'Lint markdown files' - os: linux - language: generic - install: gem install awesome_bot - script: - - find . -type f -name '*.md' -exec awesome_bot {} \; - notifications: - email: false - - - &integrationtest - stage: 'Integration tests' - merge_mode: replace - env: SDK=java SDK_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH - cache: false - language: minimal - before_install: skip - install: skip - before_script: - - mkdir $HOME/travisci-tools && pushd $HOME/travisci-tools && git init && git pull https://$CI_USER_TOKEN@github.com/optimizely/travisci-tools.git && popd - script: - - $HOME/travisci-tools/trigger-script-with-status-update.sh - after_success: travis_terminate 0 - - - <<: *integrationtest - stage: 'Full stack production tests' - env: - SDK=java - SDK_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH - FULLSTACK_TEST_REPO=ProdTesting - - - stage: 'Source Clear' - if: type = cron - install: skip - before_script: skip - script: skip - after_success: skip - - - stage: 'Publish' - if: tag IS present - script: - - ./gradlew ship - after_success: skip - - - stage: 'Snapshot' - if: env(SNAPSHOT) = true and type = api - script: - - TRAVIS_TAG=BB-SNAPSHOT ./gradlew ship - after_success: skip