From d3af08ff5d46be2c2a95810c5b3f0389df0d5faf Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 12:14:42 -0500 Subject: [PATCH 01/20] Create ci.yml --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..c6a841a10 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +# 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: detect-secrets-ci + +on: + push: + branches: [ master ] + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + toxenv: + - py{36,37,38,39},mypy + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # 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 + - name: Test with pytest + run: | + pytest From 395638e9b229b8976a6230eb209b91344511646a Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 12:22:32 -0500 Subject: [PATCH 02/20] Update ci.yml --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6a841a10..ef77ebd4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,8 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install flake8 pytest - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + tox -i https://pypi.python.org/simple -e ${{ matrix.toxenv }} - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names From 8a1f6467bce63b0e7660d9854d2a365fe58c6ba7 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 12:23:43 -0500 Subject: [PATCH 03/20] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef77ebd4e..ffee8c450 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip + pip install coveralls tox==3.2 tox-pip-extensions==1.3.0 ephemeral-port-reserve tox -i https://pypi.python.org/simple -e ${{ matrix.toxenv }} - name: Lint with flake8 run: | From 5a9ca42f00c9f78295bf163b4491b602bdc06b40 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 12:26:34 -0500 Subject: [PATCH 04/20] Update ci.yml --- .github/workflows/ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffee8c450..bc9283008 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,12 +29,6 @@ jobs: python -m pip install --upgrade pip pip install coveralls tox==3.2 tox-pip-extensions==1.3.0 ephemeral-port-reserve tox -i https://pypi.python.org/simple -e ${{ matrix.toxenv }} - - name: Lint with flake8 - run: | - # 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 - name: Test with pytest run: | pytest From 88722469555ce68aa5559b4681982911da69cdd4 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 12:29:04 -0500 Subject: [PATCH 05/20] Update ci.yml --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bc9283008..26eade84f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,3 @@ jobs: python -m pip install --upgrade pip pip install coveralls tox==3.2 tox-pip-extensions==1.3.0 ephemeral-port-reserve tox -i https://pypi.python.org/simple -e ${{ matrix.toxenv }} - - name: Test with pytest - run: | - pytest From 89629250ba03d2a615befc1aa702c8f9525e4263 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 12:33:41 -0500 Subject: [PATCH 06/20] Update ci.yml --- .github/workflows/ci.yml | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26eade84f..fb8a46399 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,23 +9,15 @@ on: pull_request: jobs: - build: - - runs-on: ubuntu-latest + main: strategy: - fail-fast: false matrix: - toxenv: - - py{36,37,38,39},mypy - + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + - uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install coveralls tox==3.2 tox-pip-extensions==1.3.0 ephemeral-port-reserve - tox -i https://pypi.python.org/simple -e ${{ matrix.toxenv }} + python-version: ${{ matrix.python }} + - run: python -mpip install --upgrade setuptools pip tox virtualenv + - run: tox -e py From 28b9c092ec94705a12ea693ac7a8dfd1ae2a0635 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 12:36:37 -0500 Subject: [PATCH 07/20] Remove python 3.10 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fb8a46399..f7ed092a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: main: strategy: matrix: - python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + python: ['3.6', '3.7', '3.8', '3.9'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 9aba7033b6e313669f8a8f71607f5aa8df602220 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 16:20:51 -0500 Subject: [PATCH 08/20] Update ci.yml Test py36 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7ed092a2..a9e13ba01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: main: strategy: matrix: - python: ['3.6', '3.7', '3.8', '3.9'] + python: ['3.6'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 55db20f5a0cd722d2d43d3de2531058caa9307cc Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Mon, 24 Jan 2022 16:27:30 -0500 Subject: [PATCH 09/20] Add py37 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9e13ba01..ba8c5f5bd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: main: strategy: matrix: - python: ['3.6'] + python: ['3.6', '3.7'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 9c34e01b21bd946fd3f6962bfdc78e50b147c887 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 25 Jan 2022 09:41:16 -0800 Subject: [PATCH 10/20] Add fix for hook --- detect_secrets/core/secrets_collection.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/detect_secrets/core/secrets_collection.py b/detect_secrets/core/secrets_collection.py index 05f770a73..91d428cd0 100644 --- a/detect_secrets/core/secrets_collection.py +++ b/detect_secrets/core/secrets_collection.py @@ -241,8 +241,14 @@ def __eq__(self, other: Any, strict: bool = False) -> bool: return False for filename in self.files: - self_mapping = {secret.secret_hash: secret for secret in self[filename]} - other_mapping = {secret.secret_hash: secret for secret in other[filename]} + self_mapping = { + (secret.secret_hash, secret.type): secret + for secret in self[filename] + } + other_mapping = { + (secret.secret_hash, secret.type): secret + for secret in other[filename] + } # Since PotentialSecret is hashable, we compare their identities through this. if set(self_mapping.values()) != set(other_mapping.values()): @@ -252,7 +258,7 @@ def __eq__(self, other: Any, strict: bool = False) -> bool: continue for secretA in self_mapping.values(): - secretB = other_mapping[secretA.secret_hash] + secretB = other_mapping[(secretA.secret_hash, secretA.type)] valuesA = vars(secretA) valuesA.pop('secret_value') From 62ee6c1da1130c6338d407f28959e984a9a807d0 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 25 Jan 2022 12:46:13 -0500 Subject: [PATCH 11/20] Add 3.8 and 3.9 back --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ba8c5f5bd..f7ed092a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: main: strategy: matrix: - python: ['3.6', '3.7'] + python: ['3.6', '3.7', '3.8', '3.9'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 6c0cdbf3fd26d2c539a02b3adbcaca4c9bc8293a Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 25 Jan 2022 12:54:57 -0500 Subject: [PATCH 12/20] Try to add mypy as env --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f7ed092a2..37940e869 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: main: strategy: matrix: - python: ['3.6', '3.7', '3.8', '3.9'] + python: ['3.6', '3.7', '3.8', '3.9', 'mypy'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 04530016626b03973ceae66de78c7170681a35ff Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 25 Jan 2022 13:04:48 -0500 Subject: [PATCH 13/20] Remove mypy from matrix and add as step --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37940e869..e82475c21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ jobs: main: strategy: matrix: - python: ['3.6', '3.7', '3.8', '3.9', 'mypy'] + python: ['3.6', '3.7', '3.8', '3.9'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -21,3 +21,4 @@ jobs: python-version: ${{ matrix.python }} - run: python -mpip install --upgrade setuptools pip tox virtualenv - run: tox -e py + - run: tox -e mypy From bb9a162f2abd3aa010168c8b89dbd70a8df22fd3 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 25 Jan 2022 13:16:01 -0500 Subject: [PATCH 14/20] Add windows and macos --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e82475c21..2f5a485a3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: python: ['3.6', '3.7', '3.8', '3.9'] - runs-on: ubuntu-latest + runs-on: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 From c82922da2ba62945a066b08a62185cdd3a4388b3 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 25 Jan 2022 13:32:13 -0500 Subject: [PATCH 15/20] Update os --- .github/workflows/ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f5a485a3..3b0bced91 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,10 +10,11 @@ on: jobs: main: + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, windows-latest, macos-latest] python: ['3.6', '3.7', '3.8', '3.9'] - runs-on: [ubuntu-latest, windows-latest, macos-latest] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 From 1aed250cde0635c6e0b200bb4ec13ca2e4f3bf3c Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 25 Jan 2022 13:41:44 -0500 Subject: [PATCH 16/20] Temporarily remove 3.8/3.9 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b0bced91..28b391a6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] - python: ['3.6', '3.7', '3.8', '3.9'] + python: ['3.6', '3.7'] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 From a030358a3ab245183e5318677b73423ea3b4c292 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Tue, 25 Jan 2022 14:09:51 -0500 Subject: [PATCH 17/20] Back to ubuntu --- .github/workflows/ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 28b391a6e..e82475c21 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,11 +10,10 @@ on: jobs: main: - runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python: ['3.6', '3.7'] + python: ['3.6', '3.7', '3.8', '3.9'] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 From 4acedd029f729a82ae28e238a763a8e0b1e4d634 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Wed, 26 Jan 2022 09:57:34 -0500 Subject: [PATCH 18/20] Update ci.yml --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e82475c21..ed7a86ca9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,10 +10,11 @@ on: jobs: main: + runs-on: ${{ matrix.os }} strategy: matrix: - python: ['3.6', '3.7', '3.8', '3.9'] - runs-on: ubuntu-latest + os: [ubuntu-latest, macos-latest] + python: ['3.6', '3.7'] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 From e443f7b1fdecb725d1f394d3741256e3e478ad71 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Wed, 26 Jan 2022 10:07:34 -0500 Subject: [PATCH 19/20] Update ci.yml --- .github/workflows/ci.yml | 4 ++-- detect_secrets/core/secrets_collection.py | 12 +++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed7a86ca9..d59e696b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,12 +14,12 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - python: ['3.6', '3.7'] + python: ['3.6', '3.7', '3.8', '3.9'] steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 with: python-version: ${{ matrix.python }} - - run: python -mpip install --upgrade setuptools pip tox virtualenv + - run: python -m pip install --upgrade setuptools pip tox virtualenv - run: tox -e py - run: tox -e mypy diff --git a/detect_secrets/core/secrets_collection.py b/detect_secrets/core/secrets_collection.py index 91d428cd0..05f770a73 100644 --- a/detect_secrets/core/secrets_collection.py +++ b/detect_secrets/core/secrets_collection.py @@ -241,14 +241,8 @@ def __eq__(self, other: Any, strict: bool = False) -> bool: return False for filename in self.files: - self_mapping = { - (secret.secret_hash, secret.type): secret - for secret in self[filename] - } - other_mapping = { - (secret.secret_hash, secret.type): secret - for secret in other[filename] - } + self_mapping = {secret.secret_hash: secret for secret in self[filename]} + other_mapping = {secret.secret_hash: secret for secret in other[filename]} # Since PotentialSecret is hashable, we compare their identities through this. if set(self_mapping.values()) != set(other_mapping.values()): @@ -258,7 +252,7 @@ def __eq__(self, other: Any, strict: bool = False) -> bool: continue for secretA in self_mapping.values(): - secretB = other_mapping[(secretA.secret_hash, secretA.type)] + secretB = other_mapping[secretA.secret_hash] valuesA = vars(secretA) valuesA.pop('secret_value') From 00816f9dfb94b547c2ab08db04778cb223745250 Mon Sep 17 00:00:00 2001 From: John-Paul Dakran Date: Fri, 28 Jan 2022 06:37:47 -0800 Subject: [PATCH 20/20] Add comment to describe behavior of running tox -e py --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d59e696b4..bfccb36ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,5 +21,7 @@ jobs: with: python-version: ${{ matrix.python }} - run: python -m pip install --upgrade setuptools pip tox virtualenv + # Run tox only for the installed py version on the runner as outlined in the python matrix + # Ensures the correct py version is installed and tested as opposed to 'tox' which attempts to run for all py versions in tox.ini - run: tox -e py - run: tox -e mypy