From 42234e277547b18c22fa5c323e8548ac53da0cfb Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Wed, 3 May 2023 21:14:06 -0700 Subject: [PATCH 1/8] Add workflow dbt-labs/hologram/build-all --- .github/workflows/build-all.yml | 133 ++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 .github/workflows/build-all.yml diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml new file mode 100644 index 0000000..a3f2b2a --- /dev/null +++ b/.github/workflows/build-all.yml @@ -0,0 +1,133 @@ +name: dbt-labs/hologram/build-all +on: + push: + branches: + - master +jobs: + lint: + runs-on: ubuntu-latest + container: + image: python:3.9 + steps: + - uses: actions/checkout@v3.5.0 + - name: restore_cache + uses: actions/cache@v3.3.1 + with: + key: v1-lint-{{ checksum "setup.py" }} + restore-keys: |- + v1-lint-{{ checksum "setup.py" }} + v1-lint- + path: "./venv" + - name: Setup + run: |- + python3 -m venv venv + . venv/bin/activate + pip install . black mypy + - name: Check code formatting + run: |- + . venv/bin/activate + black --check hologram/ tests/ + - name: Run mypy + run: |- + . venv/bin/activate + mypy hologram --ignore-missing-imports + py36: + runs-on: ubuntu-latest + container: + image: python:3.6 + needs: + - lint + steps: + - uses: actions/checkout@v3.5.0 + - name: restore_cache + uses: actions/cache@v3.3.1 + with: + key: v1-unit-{{ checksum "setup.py" }} + restore-keys: |- + v1-unit-{{ checksum "setup.py" }} + v1-unit- + path: "./venv" + - name: Setup + run: |- + python3 -m venv venv + . venv/bin/activate + pip install . pytest + - name: Run tests + run: |- + . venv/bin/activate + pytest + py37: + runs-on: ubuntu-latest + container: + image: python:3.7 + needs: + - lint + steps: + - uses: actions/checkout@v3.5.0 + - name: restore_cache + uses: actions/cache@v3.3.1 + with: + key: v1-unit-{{ checksum "setup.py" }} + restore-keys: |- + v1-unit-{{ checksum "setup.py" }} + v1-unit- + path: "./venv" + - name: Setup + run: |- + python3 -m venv venv + . venv/bin/activate + pip install . pytest + - name: Run tests + run: |- + . venv/bin/activate + pytest + py38: + runs-on: ubuntu-latest + container: + image: python:3.8 + needs: + - lint + steps: + - uses: actions/checkout@v3.5.0 + - name: restore_cache + uses: actions/cache@v3.3.1 + with: + key: v1-unit-{{ checksum "setup.py" }} + restore-keys: |- + v1-unit-{{ checksum "setup.py" }} + v1-unit- + path: "./venv" + - name: Setup + run: |- + python3 -m venv venv + . venv/bin/activate + pip install . pytest + - name: Run tests + run: |- + . venv/bin/activate + pytest + py39: + runs-on: ubuntu-latest + container: + image: python:3.9 + needs: + - lint + steps: + - uses: actions/checkout@v3.5.0 + - name: restore_cache + uses: actions/cache@v3.3.1 + with: + key: v1-unit-{{ checksum "setup.py" }} + restore-keys: |- + v1-unit-{{ checksum "setup.py" }} + v1-unit- + path: "./venv" + - name: Setup + run: |- + python3 -m venv venv + . venv/bin/activate + pip install . pytest + - name: Run tests + run: |- + . venv/bin/activate + pytest From 79135c3ab931468bd6cf769b86f3b2a4f05e9476 Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Wed, 3 May 2023 21:16:19 -0700 Subject: [PATCH 2/8] Update and rename build-all.yml to main.yml --- .github/workflows/build-all.yml | 133 -------------------------------- .github/workflows/main.yml | 75 ++++++++++++++++++ 2 files changed, 75 insertions(+), 133 deletions(-) delete mode 100644 .github/workflows/build-all.yml create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml deleted file mode 100644 index a3f2b2a..0000000 --- a/.github/workflows/build-all.yml +++ /dev/null @@ -1,133 +0,0 @@ -name: dbt-labs/hologram/build-all -on: - push: - branches: - - master -jobs: - lint: - runs-on: ubuntu-latest - container: - image: python:3.9 - steps: - - uses: actions/checkout@v3.5.0 - - name: restore_cache - uses: actions/cache@v3.3.1 - with: - key: v1-lint-{{ checksum "setup.py" }} - restore-keys: |- - v1-lint-{{ checksum "setup.py" }} - v1-lint- - path: "./venv" - - name: Setup - run: |- - python3 -m venv venv - . venv/bin/activate - pip install . black mypy - - name: Check code formatting - run: |- - . venv/bin/activate - black --check hologram/ tests/ - - name: Run mypy - run: |- - . venv/bin/activate - mypy hologram --ignore-missing-imports - py36: - runs-on: ubuntu-latest - container: - image: python:3.6 - needs: - - lint - steps: - - uses: actions/checkout@v3.5.0 - - name: restore_cache - uses: actions/cache@v3.3.1 - with: - key: v1-unit-{{ checksum "setup.py" }} - restore-keys: |- - v1-unit-{{ checksum "setup.py" }} - v1-unit- - path: "./venv" - - name: Setup - run: |- - python3 -m venv venv - . venv/bin/activate - pip install . pytest - - name: Run tests - run: |- - . venv/bin/activate - pytest - py37: - runs-on: ubuntu-latest - container: - image: python:3.7 - needs: - - lint - steps: - - uses: actions/checkout@v3.5.0 - - name: restore_cache - uses: actions/cache@v3.3.1 - with: - key: v1-unit-{{ checksum "setup.py" }} - restore-keys: |- - v1-unit-{{ checksum "setup.py" }} - v1-unit- - path: "./venv" - - name: Setup - run: |- - python3 -m venv venv - . venv/bin/activate - pip install . pytest - - name: Run tests - run: |- - . venv/bin/activate - pytest - py38: - runs-on: ubuntu-latest - container: - image: python:3.8 - needs: - - lint - steps: - - uses: actions/checkout@v3.5.0 - - name: restore_cache - uses: actions/cache@v3.3.1 - with: - key: v1-unit-{{ checksum "setup.py" }} - restore-keys: |- - v1-unit-{{ checksum "setup.py" }} - v1-unit- - path: "./venv" - - name: Setup - run: |- - python3 -m venv venv - . venv/bin/activate - pip install . pytest - - name: Run tests - run: |- - . venv/bin/activate - pytest - py39: - runs-on: ubuntu-latest - container: - image: python:3.9 - needs: - - lint - steps: - - uses: actions/checkout@v3.5.0 - - name: restore_cache - uses: actions/cache@v3.3.1 - with: - key: v1-unit-{{ checksum "setup.py" }} - restore-keys: |- - v1-unit-{{ checksum "setup.py" }} - v1-unit- - path: "./venv" - - name: Setup - run: |- - python3 -m venv venv - . venv/bin/activate - pip install . pytest - - name: Run tests - run: |- - . venv/bin/activate - pytest diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..1d8cdec --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,75 @@ +name: CI + +on: [push, pull_request] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: v1-lint-${{ hashFiles('setup.py') }} + restore-keys: | + v1-lint- + + - name: Install dependencies + run: | + python -m venv venv + source venv/bin/activate + pip install . black mypy + + - name: Check code formatting + run: | + source venv/bin/activate + black --check hologram/ tests/ + + - name: Run mypy + run: | + source venv/bin/activate + mypy hologram --ignore-missing-imports + + test: + needs: lint + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.cache/pip + key: v1-unit-${{ hashFiles('setup.py') }} + restore-keys: | + v1-unit- + + - name: Install dependencies + run: | + python -m venv venv + source venv/bin/activate + pip install . pytest + + - name: Run tests + run: | + source venv/bin/activate + pytest From 813d8b969cf847ba07190c2da2d28e36d24be8f3 Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Wed, 3 May 2023 21:21:05 -0700 Subject: [PATCH 3/8] black reformat file --- hologram/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/hologram/__init__.py b/hologram/__init__.py index f41d8de..e6955cb 100644 --- a/hologram/__init__.py +++ b/hologram/__init__.py @@ -381,7 +381,6 @@ def encoder(ft, val, o): # TODO: is there some way to set __args__ on this so it can # just re-use Dict/Mapping? def encoder(ft, val, o): - return { cls._encode_field(str, k, o): cls._encode_field( ft.TARGET_TYPE, v, o @@ -740,7 +739,6 @@ def _get_schema_for_type( required: bool = True, restrictions: Optional[List[Any]] = None, ) -> Tuple[JsonDict, bool]: - field_schema: JsonDict = {"type": "object"} type_name = cls._get_field_type_name(target) From 66b20885c450f81bbd5f0b2b029dee1c94d156b1 Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Wed, 3 May 2023 21:29:42 -0700 Subject: [PATCH 4/8] simplify github action --- .github/workflows/main.yml | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1d8cdec..6481f0e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,12 @@ name: CI -on: [push, pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - '**' jobs: lint: @@ -8,21 +14,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python 3.9 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: 3.9 - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: v1-lint-${{ hashFiles('setup.py') }} - restore-keys: | - v1-lint- - - name: Install dependencies run: | python -m venv venv @@ -48,21 +46,13 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: v1-unit-${{ hashFiles('setup.py') }} - restore-keys: | - v1-unit- - - name: Install dependencies run: | python -m venv venv From 1c90f58e05c82277dcda62b4c7bd28eca49b5880 Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Wed, 3 May 2023 21:43:32 -0700 Subject: [PATCH 5/8] remove circleci --- .circleci/config.yml | 104 ------------------------------------------- 1 file changed, 104 deletions(-) delete mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index cb1ab4b..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,104 +0,0 @@ -version: 2 - -jobs: - lint: - docker: - - image: circleci/python:3.9 - steps: - - checkout - - - restore_cache: - keys: - - v1-lint-{{ checksum "setup.py" }} - - v1-lint- - - - run: - name: "Setup" - command: | - python3 -m venv venv - . venv/bin/activate - pip install . black mypy - - - save_cache: - paths: - - ./venv - key: v1-lint-{{ checksum "setup.py" }} - - - run: - name: "Check code formatting" - command: | - . venv/bin/activate - black --check hologram/ tests/ - - - run: - name: "Run mypy" - command: | - . venv/bin/activate - mypy hologram --ignore-missing-imports - - py36: - docker: - - image: circleci/python:3.6 - - steps: &test-steps - - checkout - - - restore_cache: - keys: - - v1-unit-{{ checksum "setup.py" }} - # fallback to using the latest cache if no exact match is found - - v1-unit- - - - run: - name: "Setup" - command: | - python3 -m venv venv - . venv/bin/activate - pip install . pytest - - - save_cache: - paths: - - ./venv - key: v1-unit-{{ checksum "setup.py" }} - - - run: - name: "Run tests" - command: | - . venv/bin/activate - pytest - - py37: - docker: - - image: circleci/python:3.7 - - steps: *test-steps - - py38: - docker: - - image: circleci/python:3.8 - - steps: *test-steps - - py39: - docker: - - image: circleci/python:3.9 - - steps: *test-steps - -workflows: - version: 2 - build-all: - jobs: - - lint - - py36: - requires: - - lint - - py37: - requires: - - lint - - py38: - requires: - - lint - - py39: - requires: - - lint From c51f42309f17b9e3bce895ce30f43226930a3c9f Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Thu, 4 May 2023 12:04:51 -0700 Subject: [PATCH 6/8] update ci action --- .github/workflows/main.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6481f0e..32325f0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,3 +1,6 @@ +# **what**: linting (black, mypy) and testing (pytest) workflows for Hologram +# **why**: to ensure that the code is formatted correctly and that it passes all tests +# **when**: on every push to main and every pull request name: CI on: @@ -42,7 +45,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.7, 3.8, 3.9, 3.10, 3.11] steps: - name: Checkout repository From 71d658f86a173e3a2e750561d8df2f6087776364 Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Thu, 4 May 2023 12:06:26 -0700 Subject: [PATCH 7/8] remove dependency between lint and test --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 32325f0..f49bfdf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,6 @@ jobs: mypy hologram --ignore-missing-imports test: - needs: lint runs-on: ubuntu-latest strategy: matrix: From 0c13cdbf0257d17a3bf0b9f6996c4a6f3aa0fa13 Mon Sep 17 00:00:00 2001 From: Kshitij Aranke Date: Thu, 4 May 2023 13:02:37 -0700 Subject: [PATCH 8/8] quote python versions --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f49bfdf..edb67a0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -44,7 +44,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9, 3.10, 3.11] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - name: Checkout repository