Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add draft flag #49

Merged
merged 51 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4adeecf
add draft flag
emmyoop Jul 7, 2023
b874579
remove notification on draft releases
emmyoop Jul 7, 2023
1637077
refactor changes
emmyoop Jul 7, 2023
0cb610b
account for GHA bool type, fix test
emmyoop Jul 11, 2023
104b6bc
move around draft
emmyoop Jul 20, 2023
2441ffa
rework version and tag
emmyoop Jul 20, 2023
d9c42c7
fix pre-release semver patch increment
colin-rogers-dbt Jul 18, 2023
07bf3a1
refactor logging and patch increment logic
colin-rogers-dbt Jul 18, 2023
8dd5f28
more logging
emmyoop Jul 20, 2023
3033f51
move around tag and url
emmyoop Jul 20, 2023
d00bb32
add debugging to prevent breaking current builds
emmyoop Jul 20, 2023
133faf7
more debugging
emmyoop Jul 20, 2023
71ee124
more debugging
emmyoop Jul 20, 2023
74a0288
debugging
emmyoop Jul 20, 2023
6bc5cf4
and more
emmyoop Jul 20, 2023
bf2716c
generate the asset urls internally
emmyoop Jul 20, 2023
5eb4ef5
add missing import
emmyoop Jul 20, 2023
24f15c2
get config
emmyoop Jul 20, 2023
ab77620
switch to tag name
emmyoop Jul 20, 2023
a2a2d1e
use version object
emmyoop Jul 20, 2023
61919c3
WIP
emmyoop Jul 21, 2023
77208ee
add dedicated draft download and publish draft workflows
emmyoop Jul 25, 2023
de64111
rename file so i can run it
emmyoop Jul 25, 2023
ad7349c
fix file name
emmyoop Jul 25, 2023
63ff3b7
fix file name
emmyoop Jul 25, 2023
f489db8
add checkout so it's using the branch
emmyoop Jul 25, 2023
1954698
update script permissions
emmyoop Jul 25, 2023
8aff550
fix action
emmyoop Jul 25, 2023
b817af6
rename file
emmyoop Jul 25, 2023
af0331c
tweak how draft gets passed
emmyoop Jul 25, 2023
7ac5bfc
more cleanup
emmyoop Jul 25, 2023
692b01d
fix broken import
emmyoop Jul 25, 2023
28684a3
pass GH token
emmyoop Jul 25, 2023
3f4b371
enforce release is always a draft first
emmyoop Jul 31, 2023
6467756
tweak workflow snytax, add secrets
emmyoop Jul 31, 2023
04bbfc3
add workflow for full release
emmyoop Jul 31, 2023
647fc85
add logging
emmyoop Jul 31, 2023
da3d557
stub some more out
emmyoop Aug 1, 2023
1348f83
checking drafts
emmyoop Aug 2, 2023
47192d6
remove needs
emmyoop Aug 2, 2023
afbebc0
add logic for preexisting draft releases
emmyoop Aug 2, 2023
b8848c1
tweak message
emmyoop Aug 2, 2023
863d54d
tweak the publish workflow and rename workflows for testing
emmyoop Aug 2, 2023
fb4b74c
add tag output
emmyoop Aug 2, 2023
9c672b6
fix path
emmyoop Aug 2, 2023
a846c63
rename workflows, fix checkout bug, fix job name issue
emmyoop Aug 2, 2023
8d4d3d3
fix typos
emmyoop Aug 2, 2023
064deb0
final tweaks for moving to drafts
emmyoop Aug 3, 2023
8b183e9
fix test
emmyoop Aug 3, 2023
8a85ef2
drop 3.7
emmyoop Aug 10, 2023
cc22910
use better if/else
emmyoop Aug 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions .github/actions/test_install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,56 @@ name: test-bundle-install
description: "test installing a bundle for a given os/python/dbt version"

inputs:
version_number:
description: The release version number (i.e. 1.0.0b1).
required: true
tag:
description: The release version number (i.e. 1.5.12).
python_version:
description: The version of python to test against
required: true
os_platform:
description: The os platform of the worker performing the test
required: true
draft:
colin-rogers-dbt marked this conversation as resolved.
Show resolved Hide resolved
description: Whether the release is a draft
required: true

runs:
using: composite
steps:
- name: Checkout Repo
- name: "Checkout Repo"
uses: actions/checkout@v3

- name: Set up Python "${{ inputs.python_version }}"
- name: "Set up Python ${{ inputs.python_version }}"
uses: actions/setup-python@v4
with:
python-version: "${{ inputs.python_version }}"

- name: Install Release
- name: "Set up venv"
shell: bash
run: |
python -m venv env test_release_install
source test_release_install/bin/activate
pip install --upgrade pip

- name: "Install Published Release"
if: ${{ !inputs.draft }}
shell: bash
run: |
bash install_bundle.sh \
"${{ inputs.version_number }}" \
"${{ inputs.tag }}" \
"${{ inputs.python_version }}" \
"${{ inputs.os_platform }}"
pip freeze
dbt --version

- name: "Install Draft Release"
if: ${{ inputs.draft }}
shell: bash
run: |
bash ./.github/scripts/install_draft_bundle.sh \
"${{ inputs.tag }}" \
"${{ inputs.python_version }}" \
"${{ inputs.os_platform }}"
pip freeze
dbt --version
dbt --version
env:
GH_TOKEN: ${{ github.token }}
18 changes: 18 additions & 0 deletions .github/scripts/audit_draft_bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -e
set -e

tag="$1"
echo $tag

draft_release=$(gh release view "${tag}" --json isDraft --jq .isDraft)
echo $draft_release

if [ -z "$draft_release" ]; then
echo "Release with tag $tag does not exist."
exit 1
fi

if [ "$draft_release" = "false" ]; then
echo "Release with tag $tag is already published."
exit 1
fi
23 changes: 23 additions & 0 deletions .github/scripts/install_draft_bundle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash -e
set -e

tag="$1"
python_version="$2"
os_platform="$3"
suffix="${os_platform}_${python_version}"

archive_file="bundle_core_all_adapters_${suffix}.zip"
requirements_file="bundle_requirements_${suffix}.txt"
echo $suffix
export DBT_PSYCOPG2_NAME=psycopg2
gh release download "${tag}" -p "${archive_file}"
gh release download "${tag}" -p "${requirements_file}"
unzip -o "${archive_file}" -d bundle_pkgs
pip install -r "${requirements_file}" \
--no-index \
--no-cache-dir \
--ignore-installed \
--find-links ./bundle_pkgs \
--pre

unset DBT_PSYCOPG2_NAME
19 changes: 19 additions & 0 deletions .github/scripts/supported_python_versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -e

# 1.0 to 1.3 support python 3.7 to 3.10
# 1.4 added support for python 3.11
# 1.6 drops support for python 3.7
# Note that Python 3.8 is manually added to the matrix so not included here

minor_version="$1"
if [[ ${minor_version} < 4 ]]
then
py_versions='["3.7", "3.8", "3.9", "3.10"]'
emmyoop marked this conversation as resolved.
Show resolved Hide resolved
elif [[ ${minor_version} < 6 ]]
then
py_versions='["3.7", "3.8", "3.9", "3.10", "3.11"]'
else
py_versions='["3.8", "3.9", "3.10", "3.11"]'
fi
echo $py_versions
echo "versions=$py_versions" >> "$GITHUB_OUTPUT"
125 changes: 125 additions & 0 deletions .github/workflows/publish_draft_bundle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# **what?**
# Moves a bundle from draft to published. Then tests all installtion methods.

# **why?**
# This allows testing a bundle before officially releasing it.

# **when?**
# This is currently triggered manually.

# **how**
# Call workflow dispatch. For input-version please use the semantic version
# representing the release of the dependency you want to incorporate into a new
# bundle.

name: Publish a Draft Bundle
run-name: Publishing the draft bundle for ${{ inputs.tag }}
permissions:
packages: read
contents: write
pull-requests: read

on:
workflow_dispatch:
inputs:
tag:
description: The draft release tag (i.e. 1.5.17).
type: string
required: true

workflow_call:
inputs:
tag:
description: The draft release tag (i.e. 1.5.17).
type: string
required: true

jobs:
publish-bundle:
name: "Publish the bundle"
runs-on: ubuntu-latest

steps:
- name: "Checkout Repo"
uses: actions/checkout@v3

# non-zero exit code when the release does not exist and is not currently in draft status
- name: "Check bundle exists in draft state"
shell: bash
run: |
bash ./.github/scripts/audit_draft_bundle.sh "${{ inputs.tag }}"
env:
GH_TOKEN: ${{ github.token }}

- name: "Publish draft bundle"
id: publish-draft
run: |
echo ${{ inputs.tag }}
gh release edit ${{ inputs.tag }} --draft=false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-python-matrix:
name: "Audit Version and Build Python Release Matrix"
runs-on: ubuntu-latest
needs: ["publish-bundle"]
outputs:
python_versions: ${{ steps.build-list.outputs.versions }}

steps:
- name: "Checkout Repo"
uses: actions/checkout@v3

- name: "Audit Version And Parse Into Parts"
id: semver
uses: dbt-labs/actions/[email protected]
with:
version: ${{ inputs.tag }}

- name: "Set Python Versions"
id: build-list
run: ./.github/scripts/supported_python_versions.sh ${{ steps.semver.outputs.minor }}

- name: Print Support of Python Versions Other Than 3.8
run: |
echo "${{ steps.build-list.outputs.versions }}"

test-bundle:
needs: [build-python-matrix]
strategy:
# run even if some fail so we get a full picture. At this point linux/3.8 is already released anyways so there's no reason to stop
fail-fast: false
matrix:
python-version: ${{ fromJSON(needs.build-python-matrix.outputs.python_versions) }}
os: ["macos-latest", "ubuntu-latest"]

name: ${{ matrix.os }} - ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

steps:
- name: "Checkout Repo"
uses: actions/checkout@v3

- name: "Set Linux OS"
if: matrix.os == 'ubuntu-latest'
run: |
echo "os_platform=linux" >> $GITHUB_ENV

- name: "Set Mac OS"
if: matrix.os == 'macos-latest'
run: |
echo "os_platform=mac" >> $GITHUB_ENV

- name: "Test install from Github Release"
uses: ./.github/actions/test_install
with:
tag: "${{ inputs.tag }}"
python_version: "${{ matrix.python-version }}"
os_platform: "${{ env.os_platform }}"
draft: false

- name: "Post Notification"
run: |
title="Test Install Successful"
message="Installation and version command run successful for os_platform=${{ matrix.os }}, Python=${{ matrix.python-version }}, version=${{ inputs.tag }}"
echo "::notice $title::$message"
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# **what?**
# This workflow generates a zip archive with all the python dependencies
# needed to run core + all adapters for linux, mac OS platforms (future ToDo: add Windows)
# It will release to GitHub as a draft release.

# **why?**
# Installing from pip can result in unpredictable installs/runtime environments.
Expand All @@ -16,25 +17,31 @@
# bundle. So if there has just been a release of dbt-core of 1.3.3 then pass that
# as the input version (without a `v` prefix).

name: Release a Bundle
run-name: Releasing a bundle for ${{ inputs.version_number }}
name: Release a Draft Bundle
run-name: Drafting a release bundle for ${{ inputs.version_number }}
permissions:
packages: read
contents: write
pull-requests: read

on:
workflow_dispatch:
inputs:
version_number:
description: The release version number (i.e. 1.0.0b1).
type: string
required: true

workflow_call:
inputs:
version_number:
description: The release version number (i.e. 1.0.0b1).
type: string
required: true
outputs:
tag:
description: "The tag of the release that was created."
value: ${{ jobs.create-bundle.outputs.created_tag }}

jobs:
build-python-matrix:
Expand All @@ -44,30 +51,18 @@ jobs:
python_versions: ${{ steps.build-list.outputs.versions }}

steps:
- name: "Checkout Repo"
uses: actions/checkout@v3

- name: "Audit Version And Parse Into Parts"
id: semver
uses: dbt-labs/actions/[email protected]
with:
version: ${{ inputs.version_number }}

- name: "Set Python Versions"
# 1.0 to 1.3 support python 3.7 to 3.10
# 1.4 added support for python 3.11
# 1.6 drops support for python 3.7
# Note that Python 3.8 is manually added to the matrix so not included here
id: build-list
run: |
if [[ ${{ steps.semver.outputs.minor }} < 4 ]]
then
py_versions='["3.7", "3.9", "3.10"]'
elif [[ ${{ steps.semver.outputs.minor }} < 6 ]]
then
py_versions='["3.7", "3.9", "3.10", "3.11"]'
else
py_versions='["3.9", "3.10", "3.11"]'
fi
echo $py_versions
echo "versions=$py_versions" >> "$GITHUB_OUTPUT"
run: ./.github/scripts/supported_python_versions.sh ${{ steps.semver.outputs.minor }}

- name: Print Support of Python Versions Other Than 3.8
run: |
Expand All @@ -80,6 +75,8 @@ jobs:
GH_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
created_tag: ${{ steps.create-release.outputs.created_tag }}
created_asset_url: ${{ steps.create-release.outputs.created_asset_url }}
req_file_url: ${{ steps.create-release.outputs.req_file_url }}
steps:
- name: "Checkout Repo"
uses: actions/checkout@v3
Expand All @@ -104,16 +101,14 @@ jobs:
python -u -m release_creation.main \
--input-version=${{ inputs.version_number }} \
--operation=create
source ./result.env
echo "$CREATED_TAG"
echo "created_tag=$CREATED_TAG" >> $GITHUB_OUTPUT


- name: "Test install from Github Release"
uses: ./.github/actions/test_install
with:
version_number: ${{ steps.create-release.outputs.created_tag }}
tag: "${{ steps.create-release.outputs.created_tag }}"
python_version: "3.8"
os_platform: "linux"
draft: true

- name: "Post Notification"
run: |
Expand All @@ -129,9 +124,9 @@ jobs:
matrix:
python-version: ${{ fromJSON(needs.build-python-matrix.outputs.python_versions) }}
os: ["macos-latest", "ubuntu-latest"]
include:
exclude:
- python-version: 3.8
os: macos-latest
os: ubuntu-latest
name: ${{ matrix.os }} - ${{ matrix.python-version }}
env:
GH_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -173,9 +168,10 @@ jobs:
- name: "Test install from Github Release"
uses: ./.github/actions/test_install
with:
version_number: ${{ needs.create-bundle.outputs.created_tag }}
python_version: ${{ matrix.python-version }}
os_platform: ${{ env.os_platform }}
tag: "${{ needs.create-bundle.outputs.created_tag }}"
python_version: "${{ matrix.python-version }}"
os_platform: "${{ env.os_platform }}"
draft: true

- name: "Post Notification"
run: |
Expand Down
Loading
Loading