From 829c0880d4f139fada5c35303dc373fc0e7e3abd Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Wed, 13 Apr 2022 19:54:47 +0500 Subject: [PATCH 01/13] Adding python githubaction --- .github/workflows/python.yml | 80 ++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 .github/workflows/python.yml diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 000000000..b7a540866 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,80 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Python package + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +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 {} \; + + linting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.9 + uses: actions/setup-python@v3 + with: + python-version: 3.9 + # flake8 version should be same as the version in requirements/test.txt + # to avoid lint errors on CI + - name: pip install flak8 + run: pip install flake8>=4.1.0 + - name: Lint with flake8 + run: | + flake8 + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + + integration_tests: + uses: optimizely/python-sdk/.github/workflows/integration_test.yml@mnoman/gitAction + secrets: + CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} + TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} + + fullstack_production_suite: + uses: optimizely/python-sdk/.github/workflows/integration_test.yml@mnoman/gitAction + with: + FULLSTACK_TEST_REPO: ProdTesting + secrets: + CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} + TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} + + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["pypy3.7-7.3.5", "3.7", "3.8", "3.9", "3.10.0"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements/core.txt;pip install -r requirements/test.txt + - name: Test with pytest + run: | + pytest --cov=optimizely From e0428e69517d4c1e3182324facf69b9776fc05d0 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Wed, 13 Apr 2022 19:55:36 +0500 Subject: [PATCH 02/13] added integration yml --- .github/workflows/integration_test.yml | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/integration_test.yml 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 From 5e0ffbfae69e7b83a51b93b14e90265eb53f3fa4 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Wed, 13 Apr 2022 19:56:32 +0500 Subject: [PATCH 03/13] Create source clear cron job file --- .github/workflows/source_clear_cron.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/source_clear_cron.yml 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 From adc8342dd31bf57ae8473ca2d2123b9411e3122e Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Wed, 13 Apr 2022 20:11:48 +0500 Subject: [PATCH 04/13] fix --- .github/workflows/integration_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index e4d1c7e7d..bb640f0e7 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -34,7 +34,7 @@ jobs: echo "TRAVIS_BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV - name: Trigger build env: - SDK: java + SDK: python FULLSTACK_TEST_REPO: ${{ inputs.FULLSTACK_TEST_REPO }} BUILD_NUMBER: ${{ github.run_id }} TESTAPP_BRANCH: master From efb35969c62db5b8488bfb96559e45f4aad215f6 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Wed, 13 Apr 2022 20:12:18 +0500 Subject: [PATCH 05/13] fix pypy version --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index b7a540866..6e6ac0de9 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -64,7 +64,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["pypy3.7-7.3.5", "3.7", "3.8", "3.9", "3.10.0"] + python-version: ["pypy-3.7", "3.7", "3.8", "3.9", "3.10.0"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 7649e93d9cf7f15c67637bc67bc2cadd9439676a Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Wed, 13 Apr 2022 20:13:54 +0500 Subject: [PATCH 06/13] test --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6e6ac0de9..6b7280fdd 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -64,7 +64,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["pypy-3.7", "3.7", "3.8", "3.9", "3.10.0"] + python-version: ["pypy-3.7-v7.3.5", "3.7", "3.8", "3.9", "3.10.0"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 7dce505f580b6efd7de805e5971f95737e63b32e Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Wed, 13 Apr 2022 20:14:55 +0500 Subject: [PATCH 07/13] v2 to v3 --- .github/workflows/python.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 6b7280fdd..bf8120da8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -13,7 +13,7 @@ jobs: lint_markdown_files: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From 626a03554789da7d632b207e4df60b17a776c0cd Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Wed, 13 Apr 2022 20:58:18 +0500 Subject: [PATCH 08/13] delete travis.yml --- .travis.yml | 84 ----------------------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dc0081886..000000000 --- a/.travis.yml +++ /dev/null @@ -1,84 +0,0 @@ -dist: focal -language: python -python: - - "pypy3.7-7.3.5" - - "3.7" - - "3.8" - - "3.9" - - "3.10.0" -before_install: "python -m pip install --upgrade pip" -install: "pip install -r requirements/core.txt;pip install -r requirements/test.txt" -script: "pytest --cov=optimizely" -after_success: - - coveralls - -# Linting and Integration tests need to run first to reset the PR build status to pending. -stages: - - 'Source Clear' - - 'Lint markdown files' - - 'Linting' - - 'Integration tests' - - 'Full stack production tests' - - 'Test' - -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 - - - stage: 'Linting' - language: python - python: "3.9" - # flake8 version should be same as the version in requirements/test.txt - # to avoid lint errors on CI - install: "pip install flake8>=4.1.0" - script: "flake8" - after_success: travis_terminate 0 - - - &integrationtest - stage: 'Integration tests' - merge_mode: replace - env: SDK=python SDK_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH - cache: false - language: minimal - 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=python - SDK_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH - FULLSTACK_TEST_REPO=ProdTesting - - stage: 'Test' - python: "pypy3.7-7.3.5" -# before_install: -# - pip install "cryptography>=1.3.4" - - stage: 'Test' - python: "3.7" - - stage: 'Test' - python: "3.8" - - stage: 'Test' - python: "3.9" - - stage: 'Test' - python: "3.10.0" - - - stage: 'Source Clear' - if: type = cron - addons: - srcclr: true - before_install: skip - install: skip - before_script: skip - script: skip - after_success: skip From 956b0336bb52632fd1c5f603f22765fb6523cedd Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Thu, 14 Apr 2022 20:58:53 +0500 Subject: [PATCH 09/13] Changed action checkout to v3 --- .github/workflows/integration_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index bb640f0e7..c42d6558f 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -15,7 +15,7 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: # You should create a personal access token and store it in your repository token: ${{ secrets.CI_USER_TOKEN }} From 19cc4d3e2c138010aeb350fd13d96b15ffa61b94 Mon Sep 17 00:00:00 2001 From: Muhammad Noman Date: Thu, 14 Apr 2022 21:05:21 +0500 Subject: [PATCH 10/13] changed branch target to master --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index bf8120da8..574472de0 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -46,13 +46,13 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics integration_tests: - uses: optimizely/python-sdk/.github/workflows/integration_test.yml@mnoman/gitAction + uses: optimizely/python-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/python-sdk/.github/workflows/integration_test.yml@mnoman/gitAction + uses: optimizely/python-sdk/.github/workflows/integration_test.yml@master with: FULLSTACK_TEST_REPO: ProdTesting secrets: From 662366f50e2f17c8740268aa30268437884af5e3 Mon Sep 17 00:00:00 2001 From: Mirza Sohail Hussain Date: Tue, 26 Apr 2022 15:24:55 -0700 Subject: [PATCH 11/13] Apply suggestions from code review --- .github/workflows/integration_test.yml | 1 - .github/workflows/source_clear_cron.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/integration_test.yml b/.github/workflows/integration_test.yml index c42d6558f..c0bc89081 100644 --- a/.github/workflows/integration_test.yml +++ b/.github/workflows/integration_test.yml @@ -26,7 +26,6 @@ jobs: 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: | diff --git a/.github/workflows/source_clear_cron.yml b/.github/workflows/source_clear_cron.yml index 54eca5358..862b4a3f9 100644 --- a/.github/workflows/source_clear_cron.yml +++ b/.github/workflows/source_clear_cron.yml @@ -9,7 +9,7 @@ jobs: source_clear: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Source clear scan env: SRCCLR_API_TOKEN: ${{ secrets.SRCCLR_API_TOKEN }} From 380e59f405821bf5b4a4082103b18c9a2cee7114 Mon Sep 17 00:00:00 2001 From: Mirza Sohail Hussain Date: Tue, 26 Apr 2022 15:51:19 -0700 Subject: [PATCH 12/13] Apply suggestions from code review --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 574472de0..bf8120da8 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -46,13 +46,13 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics integration_tests: - uses: optimizely/python-sdk/.github/workflows/integration_test.yml@master + uses: optimizely/python-sdk/.github/workflows/integration_test.yml@mnoman/gitAction secrets: CI_USER_TOKEN: ${{ secrets.CI_USER_TOKEN }} TRAVIS_COM_TOKEN: ${{ secrets.TRAVIS_COM_TOKEN }} fullstack_production_suite: - uses: optimizely/python-sdk/.github/workflows/integration_test.yml@master + uses: optimizely/python-sdk/.github/workflows/integration_test.yml@mnoman/gitAction with: FULLSTACK_TEST_REPO: ProdTesting secrets: From 10c1cdf54110fbfc3db7224f4a9a261d3f5f96ac Mon Sep 17 00:00:00 2001 From: Mirza Sohail Hussain Date: Tue, 26 Apr 2022 15:59:15 -0700 Subject: [PATCH 13/13] Apply suggestions from code review revert to master --- .github/workflows/python.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index bf8120da8..574472de0 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -46,13 +46,13 @@ jobs: flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics integration_tests: - uses: optimizely/python-sdk/.github/workflows/integration_test.yml@mnoman/gitAction + uses: optimizely/python-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/python-sdk/.github/workflows/integration_test.yml@mnoman/gitAction + uses: optimizely/python-sdk/.github/workflows/integration_test.yml@master with: FULLSTACK_TEST_REPO: ProdTesting secrets: