From 250ac993994e1633b7e3ce6e80b4191b5520997c Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 12:43:07 -0400 Subject: [PATCH 01/16] Started --- .circleci/config.yml | 65 -------------------------------------- .github/workflows/lint.yml | 42 ++++++++++++++++++++++++ .github/workflows/test.yml | 41 ++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 65 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/test.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 8e8ebe0d..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,65 +0,0 @@ -version: 2.1 - -jobs: - verify_build: - working_directory: ~/repo - docker: - - image: circleci/python:<< parameters.python >> - parameters: - python: - type: string - steps: - - checkout - - restore_cache: - keys: - - v1-dependencies-<< parameters.python >>-{{ checksum "setup.py" }} - # fallback to using the latest cache if no exact match is found - - v1-dependencies-<< parameters.python >>-- - - run: - name: Install Dependencies - command: | - pip install virtualenv - virtualenv venv - source venv/bin/activate - pip install .[dev] - - run: - name: Run Unit Tests - command: | - source venv/bin/activate - nose2 -v - - run: - name: Lint - command: | - source venv/bin/activate - flake8 datadog_lambda/ - - run: - name: Check Formatting - command: | - source venv/bin/activate - ./scripts/check_format.sh - - - save_cache: - paths: - - ./venv - key: v1-dependencies-<< parameters.python >>-{{ checksum "setup.py" }} - -workflows: - python-v2.7: - jobs: - - verify_build: - python: "2.7" - - python-v3.6: - jobs: - - verify_build: - python: "3.6" - - python-v3.7: - jobs: - - verify_build: - python: "3.7" - - python-v3.8: - jobs: - - verify_build: - python: "3.8" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..94ff1154 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,42 @@ +name: Lint + +on: push + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-node@v1 + with: + python-version: 3.7 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: | + pip install virtualenv + virtualenv venv + source venv/bin/activate + pip install .[dev] + + - name: Check formatting + run: | + source venv/bin/activate + ./scripts/check_format.sh + + - name: Lint + run: | + source venv/bin/activate + flake8 datadog_lambda/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..fb6e48ae --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: Test + +on: push + +jobs: + test: + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [2.7, 3.6, 3.7, 3.8] + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-node@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: | + pip install virtualenv + virtualenv venv + source venv/bin/activate + pip install .[dev] + + - name: Run tests + run: | + source venv/bin/activate + nose2 -v From b5149a4dff25a56638c56cf1bb2347633530beec Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 12:44:35 -0400 Subject: [PATCH 02/16] Fix indentation --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fb6e48ae..f28bf663 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,9 +6,9 @@ jobs: test: runs-on: ubuntu-latest strategy: - max-parallel: 4 - matrix: - python-version: [2.7, 3.6, 3.7, 3.8] + max-parallel: 4 + matrix: + python-version: [2.7, 3.6, 3.7, 3.8] steps: - name: Checkout From 37a313a0cc728547aae026107c95f7bf9190a0fe Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 12:49:18 -0400 Subject: [PATCH 03/16] Try without venv --- .github/workflows/test.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f28bf663..ca9bb9a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Cache dependencies + id: cache-dependencies uses: actions/cache@v2 with: path: ~/.cache/pip @@ -28,14 +29,8 @@ jobs: ${{ runner.os }}-pip- - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: | - pip install virtualenv - virtualenv venv - source venv/bin/activate - pip install .[dev] + if: steps.cache-dependencies.outputs.cache-hit != 'true' + run: pip install .[dev] - name: Run tests - run: | - source venv/bin/activate - nose2 -v + run: nose2 -v From 78e79e7837f08b69e7a55a482b8e7404f4a81430 Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 12:51:26 -0400 Subject: [PATCH 04/16] Try upgrading deps --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ca9bb9a0..54260116 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: - name: Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' - run: pip install .[dev] + run: pip install --upgrade .[dev] - name: Run tests run: nose2 -v From f7f45da86ef1ccb5b5967628094c19b0983a46b5 Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 12:56:50 -0400 Subject: [PATCH 05/16] Upgrade pip --- .github/workflows/test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54260116..66f33f1f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,9 @@ jobs: - name: Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' - run: pip install --upgrade .[dev] + run: | + python -m pip install --upgrade pip + pip install --upgrade .[dev] - name: Run tests run: nose2 -v From 84373f4f01e0e602acfaab25327cdeee576b1d20 Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 14:29:43 -0400 Subject: [PATCH 06/16] Try sudo --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 66f33f1f..bbb5e2b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,7 +32,7 @@ jobs: if: steps.cache-dependencies.outputs.cache-hit != 'true' run: | python -m pip install --upgrade pip - pip install --upgrade .[dev] + sudo pip install --upgrade .[dev] - name: Run tests run: nose2 -v From 6227c02170056d6fec511831495c2097043431d9 Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 14:31:24 -0400 Subject: [PATCH 07/16] Doh! --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 94ff1154..5f5fdf56 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-node@v1 + uses: actions/setup-python@v1 with: python-version: 3.7 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bbb5e2b1..e0c13213 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-node@v1 + uses: actions/setup-python@v1 with: python-version: ${{ matrix.python-version }} From dc2c7babf16bd3ba1293ae9b526e054b7fdd6d21 Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 14:36:06 -0400 Subject: [PATCH 08/16] Use v2 --- .github/workflows/lint.yml | 2 +- .github/workflows/test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5f5fdf56..1ddbe46d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,7 +11,7 @@ jobs: uses: actions/checkout@v2 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: 3.7 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e0c13213..d689f48d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} From 540a0bc82033da729e8693b5327b4b051221cc01 Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 16:56:51 -0400 Subject: [PATCH 09/16] Consolidate --- .github/workflows/{test.yml => build.yml} | 40 ++++++++++++++++++++- .github/workflows/lint.yml | 42 ----------------------- README.md | 2 +- 3 files changed, 40 insertions(+), 44 deletions(-) rename .github/workflows/{test.yml => build.yml} (50%) delete mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/test.yml b/.github/workflows/build.yml similarity index 50% rename from .github/workflows/test.yml rename to .github/workflows/build.yml index d689f48d..3a3eb5de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,46 @@ -name: Test +name: build on: push jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: | + pip install virtualenv + virtualenv venv + source venv/bin/activate + pip install .[dev] + + - name: Check formatting + run: | + source venv/bin/activate + ./scripts/check_format.sh + + - name: Lint + run: | + source venv/bin/activate + flake8 datadog_lambda/ + test: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 1ddbe46d..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Lint - -on: push - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: | - pip install virtualenv - virtualenv venv - source venv/bin/activate - pip install .[dev] - - - name: Check formatting - run: | - source venv/bin/activate - ./scripts/check_format.sh - - - name: Lint - run: | - source venv/bin/activate - flake8 datadog_lambda/ diff --git a/README.md b/README.md index b8901975..ffdee511 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # datadog-lambda-python -[![CircleCI](https://img.shields.io/circleci/build/github/DataDog/datadog-lambda-python)](https://circleci.com/gh/DataDog/datadog-lambda-python) +![build](https://github.com/DataDog/datadog-lambda-python/workflows/build/badge.svg) [![PyPI](https://img.shields.io/pypi/v/datadog-lambda)](https://pypi.org/project/datadog-lambda/) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/datadog-lambda) [![Slack](https://img.shields.io/badge/slack-%23serverless-blueviolet?logo=slack)](https://datadoghq.slack.com/channels/serverless/) From 688c6adb9a61c66ae4e143af6ce1c252c74db92f Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 16:58:13 -0400 Subject: [PATCH 10/16] Fix indentation --- .github/workflows/build.yml | 60 ++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3a3eb5de..058379a6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,42 +4,42 @@ on: push jobs: lint: - runs-on: ubuntu-latest + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 - steps: - - name: Checkout - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.7 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.7 + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: | + pip install virtualenv + virtualenv venv + source venv/bin/activate + pip install .[dev] - - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' - run: | - pip install virtualenv - virtualenv venv - source venv/bin/activate - pip install .[dev] + - name: Check formatting + run: | + source venv/bin/activate + ./scripts/check_format.sh - - name: Check formatting - run: | + - name: Lint + run: | source venv/bin/activate - ./scripts/check_format.sh - - - name: Lint - run: | - source venv/bin/activate - flake8 datadog_lambda/ + flake8 datadog_lambda/ test: runs-on: ubuntu-latest From b6c3af84725f4172804cf3f91f287d1e4574406a Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 17:00:43 -0400 Subject: [PATCH 11/16] Hash on setup.py --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 058379a6..bea970cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,7 +19,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} restore-keys: | ${{ runner.os }}-pip- From 3be425bf4389e9ba165fb189444b47632aa060de Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 17:07:22 -0400 Subject: [PATCH 12/16] Use virtual env --- .github/workflows/build.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bea970cb..7edbf8f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,15 +62,20 @@ jobs: uses: actions/cache@v2 with: path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} restore-keys: | ${{ runner.os }}-pip- - name: Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' run: | + pip install virtualenv + virtualenv venv + source venv/bin/activate python -m pip install --upgrade pip - sudo pip install --upgrade .[dev] + pip install --upgrade .[dev] - name: Run tests - run: nose2 -v + run: | + source venv/bin/activate + nose2 -v From 11a0a116f1d1eb5d0290a573022486132c9055ac Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 17:10:15 -0400 Subject: [PATCH 13/16] Try disabling cache --- .github/workflows/build.yml | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7edbf8f4..26e4f6d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,14 +57,14 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Cache dependencies - id: cache-dependencies - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} - restore-keys: | - ${{ runner.os }}-pip- + # - name: Cache dependencies + # id: cache-dependencies + # uses: actions/cache@v2 + # with: + # path: ~/.cache/pip + # key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + # restore-keys: | + # ${{ runner.os }}-pip- - name: Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' @@ -72,8 +72,7 @@ jobs: pip install virtualenv virtualenv venv source venv/bin/activate - python -m pip install --upgrade pip - pip install --upgrade .[dev] + pip install .[dev] - name: Run tests run: | From 841bb0bfa04b1fdf2174ab3c5d7d78ea63fd8685 Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 17:11:37 -0400 Subject: [PATCH 14/16] Bring back cache --- .github/workflows/build.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 26e4f6d6..d695c402 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -57,14 +57,14 @@ jobs: with: python-version: ${{ matrix.python-version }} - # - name: Cache dependencies - # id: cache-dependencies - # uses: actions/cache@v2 - # with: - # path: ~/.cache/pip - # key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} - # restore-keys: | - # ${{ runner.os }}-pip- + - name: Cache dependencies + id: cache-dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} + restore-keys: | + ${{ runner.os }}-pip- - name: Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' From 597267000338ed1a2952ee7c976d1292ef7031af Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 17:12:25 -0400 Subject: [PATCH 15/16] Cleanup cache code --- .github/workflows/build.yml | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d695c402..1fb72a02 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,14 +15,6 @@ jobs: with: python-version: 3.7 - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies if: steps.cache-node-modules.outputs.cache-hit != 'true' run: | @@ -57,15 +49,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Cache dependencies - id: cache-dependencies - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/setup.py') }} - restore-keys: | - ${{ runner.os }}-pip- - - name: Install dependencies if: steps.cache-dependencies.outputs.cache-hit != 'true' run: | From 2d0bc7e78118681eae6fc0b47d0935a858649db3 Mon Sep 17 00:00:00 2001 From: Nick Hinsch Date: Tue, 20 Oct 2020 17:14:25 -0400 Subject: [PATCH 16/16] Rm reference to cache hit --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1fb72a02..945a9028 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,6 @@ jobs: python-version: 3.7 - name: Install dependencies - if: steps.cache-node-modules.outputs.cache-hit != 'true' run: | pip install virtualenv virtualenv venv @@ -50,7 +49,6 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies - if: steps.cache-dependencies.outputs.cache-hit != 'true' run: | pip install virtualenv virtualenv venv