geoHeil
08/23/2022, 3:56 AMStephen Bailey
08/23/2022, 9:39 AMssh
flag and docker buildx:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push Docker image to ECR
uses: docker/build-push-action@v3
with:
push: true
tags: "${{ my_tag }}"
cache-from: type=gha
cache-to: type=gha,mode=max
ssh: default
- name: Prod Deployment to Dagster Cloud
uses: dagster-io/dagster-cloud-cicd-action/update-only@v0.2.6
with:
location-file: "locations.yaml"
dagit-url: <https://whatnot.dagster.cloud/prod>
api-token: ${{ secrets.DAGSTER_PROD_AGENT_TOKEN }}
image-tag: ${{ my_tag }}
geoHeil
08/23/2022, 9:48 AMjobs:
testing:
defaults:
run:
shell: bash -l {0}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Conda environment from environment.yml
uses: mamba-org/provision-with-micromamba@v12
with:
environment-file: environment.yml
environment-name: base
cache-downloads: true
cache-env: true
- name: Install non-conda dependencies
run: |
pip install -e .
- name: 'Yamllint'
uses: karancode/yamllint-github-action@v2.0.0
with:
yamllint_file_or_dir: 'yamllint_config.yaml'
yamllint_strict: true
yamllint_comment: true
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checking formatting
run: black --check MY_PROJECT MY_PROJECT_tests && isort --check-only MY_PROJECT MY_PROJECT_tests
- name: If needed, commit black & isort changes to the pull request
if: failure()
run: |
black MY_PROJECT MY_PROJECT_tests && isort MY_PROJECT MY_PROJECT_tests
git config --global user.name 'autoblack'
git config --global user.email '<mailto:autoblack_bot@corp.com|autoblack_bot@corp.com>'
git remote set-url origin <https://x-access-token>:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
git checkout $GITHUB_HEAD_REF
git commit -am "fixup: Format Python code with Black"
git push
- name: Linting flake8
run: flake8 MY_PROJECT MY_PROJECT_tests
- name: Checking types
run: mypy MY_PROJECT MY_PROJECT_tests
- name: setup of DBT dependencies
run: cd MY_PROJECT_dbt && dbt deps
- name: Unit-tests
run: pytest --ignore=MY_PROJECT_dbt/dbt_packages .
and then secondly reach out to the deployment (or preview) (and create a tag on master)
branches:
- main
jobs:
called_testing:
uses: ./.github/workflows/1testing.yml
release:
needs: called_testing
runs-on: ubuntu-latest
steps:
- name: install zest
run: pip install zest.releaser==6.22.2
- name: checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.BUILD_SVC_PAT }}
- name: make release
run: |
git config --global user.name 'autorelease'
git config --global user.email '<mailto:autorelease_bot@corp.com|autorelease_bot@corp.com>'
git remote set-url origin <https://x-access-token>:${{ secrets.BUILD_SVC_PAT }}@github.com/$GITHUB_REPOSITORY
fullrelease --no-input
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: <http://ghcr.io|ghcr.io>
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Run Dagster Cloud CI/CD action
uses: dagster-io/dagster-cloud-cicd-action/deploy@v0.2.5
with:
location-file: locations.yaml
dagit-url: https://${{ secrets.DAGSTER_CLOUD_ORGANIZATION }}.dagster.cloud/${{ secrets.DAGSTER_CLOUD_DEPLOYMENT }}
api-token: ${{ secrets.DAGSTER_CLOUD_AGENT_TOKEN }}
where: dagster-io/dagster-cloud-cicd-action/deploy
is building the whole dockerfile (from scratch without caching) (not re-using i.e. the already installed dependencies from before).Stephen Bailey
08/23/2022, 10:03 AMupdate-only
version of the cloud ci/cd action, so that you can customize the caching with the buildx action to something you prefer.
If you want to just do one install of the dependencies, you'd probably need to build your updated docker image first, then run your tests in that container, then push that image if it worksgeoHeil
08/23/2022, 10:07 AMStephen Bailey
08/23/2022, 10:15 AMdocker run my_image format
, docker run my_image lint
, etc.geoHeil
08/23/2022, 11:19 AMmake fmt-docker
make lint-docker
make test-myrepository
to translate the steps directly into the container.
- The things around caching are still unclear to me.
- How to handle side effects (inside/outside the container)?:
- The autoformatter was actually trying to auto-format (and then commit the changes)
- the release incrementer was changing the tag and pushingdocker/build-push-action@v3
I would think it makes sense to do the linting/testing (to only publish the image in case the tests succeed.cache_from
/`cache_to` references. However, in the logs I can read that: importing cache manifest from type=gha #10 ERROR: invalid reference format
it is somehow not happy.Stephen Bailey
08/25/2022, 3:45 PMwith: {push: False}
? in the cache_base_builder
step?geoHeil
08/25/2022, 8:15 PM