From 487f62348158ff24abe9c7e974a68e0518fc2d15 Mon Sep 17 00:00:00 2001 From: Jasper Ginn Date: Sat, 6 Jan 2024 14:37:10 +0100 Subject: [PATCH] build: fix build pipeline --- .github/workflows/pipeline.yaml | 18 ++++------ .../workflows/templates/checks/action.yaml | 36 ++++++++++++++++--- .pre-commit-config.yaml | 2 +- dags/luchtmeetnet_ingestion/BUILD | 2 +- pants.toml | 1 + 5 files changed, 41 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pipeline.yaml b/.github/workflows/pipeline.yaml index b4e3129..e24d634 100644 --- a/.github/workflows/pipeline.yaml +++ b/.github/workflows/pipeline.yaml @@ -18,6 +18,8 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + with: + fetch-depth: "100" - name: 'checks' uses: ./.github/workflows/templates/checks build: @@ -36,19 +38,11 @@ jobs: with: # cache0 makes it easy to bust the cache if needed gha-cache-key: cache0-py310 - named-caches-hash: ${{ hashFiles('lockfiles/*.json', '**/something-else.lock') }} + named-caches-hash: ${{ hashFiles('python-default.lock') }} + cache-lmdb-store: 'true' - name: 'docker login' run: docker login -u _json_key -p "$ARTIFACT_SA" europe-west4-docker.pkg.dev env: ARTIFACT_SA: ${{ secrets.GOOGLE_CREDENTIALS }} - - name: 'build' - run: pants package dags/luchtmeetnet_ingestion - - name: 'add tags' - run: | - docker tag \ - europe-west4-docker.pkg.dev/jasperg-dagster/regi-areg-euw4-dagi-prd/luchtmeetnet_ingestion:latest \ - europe-west4-docker.pkg.dev/jasperg-dagster/regi-areg-euw4-dagi-prd/luchtmeetnet_ingestion:$(git rev-parse --short HEAD) - - name: 'push to gcr' - run: | - docker push europe-west4-docker.pkg.dev/jasperg-dagster/regi-areg-euw4-dagi-prd/luchtmeetnet_ingestion:latest - docker push europe-west4-docker.pkg.dev/jasperg-dagster/regi-areg-euw4-dagi-prd/luchtmeetnet_ingestion:$(git rev-parse --short HEAD) + - name: 'publish to gcr' + run: VERSION=$(git rev-parse --short HEAD) pants --filter-target-type=docker_image publish dags/luchtmeetnet_ingestion:img diff --git a/.github/workflows/templates/checks/action.yaml b/.github/workflows/templates/checks/action.yaml index 561e8a2..726e82e 100644 --- a/.github/workflows/templates/checks/action.yaml +++ b/.github/workflows/templates/checks/action.yaml @@ -16,14 +16,42 @@ runs: gha-cache-key: cache0-py310 named-caches-hash: ${{ hashFiles('lockfiles/*.json', '**/something-else.lock') }} - name: format - run: just fmt + run: | + pants \ + --changed-since=origin/main \ + tailor --check \ + update-build-files --check \ + fmt shell: bash - name: lint - run: just lint + run: | + pants \ + --changed-since=origin/main \ + lint shell: bash + # - name: type checks + # run: | + # pants \ + # --changed-since=origin/main \ + # --changed-dependents=transitive \ + # check + # shell: bash - name: test - run: just test + run: | + pants \ + --changed-since=origin/main \ + --changed-dependents=transitive \ + test shell: bash - name: package - run: just package + run: | + pants \ + --changed-since=origin/main \ + package shell: bash + - name: Upload pants log + uses: actions/upload-artifact@v3 + with: + name: pants-log + path: .pants.d/pants.log + if: always() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8fb87b0..c6b64d1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,7 +31,7 @@ repos: # hooks: # - id: pants-check # name: pants-check - # entry: "pants check --changed-since=HEAD" + # entry: "pants check --changed-since=HEAD --changed-dependents=transitive" # Checks require that we also check dependents # language: system # types: [python] # pass_filenames: false diff --git a/dags/luchtmeetnet_ingestion/BUILD b/dags/luchtmeetnet_ingestion/BUILD index 6cce18d..72bcd4e 100644 --- a/dags/luchtmeetnet_ingestion/BUILD +++ b/dags/luchtmeetnet_ingestion/BUILD @@ -73,5 +73,5 @@ docker_image( "COPY dags.luchtmeetnet_ingestion/binary-srcs.pex/pyproject.toml /pyproject.toml", 'ENTRYPOINT ["/bin/app/pex"]', ], - image_tags=["latest"], + image_tags=["latest", "{build_args.VERSION}"], ) diff --git a/pants.toml b/pants.toml index bdec612..aab3b1a 100644 --- a/pants.toml +++ b/pants.toml @@ -43,6 +43,7 @@ use_coverage = true env_vars = [ "DOCKER_BUILDKIT=0", ] +build_args = ["VERSION"] [environments-preview.names] py39_slim = "//:py39-slim"