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

Encapsulate upload step #7800

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ steps:

- label: Upload Release Artifacts
command: .buildkite/setup_and_upload_artifact.sh
agents:
vader=true
if: build.tag != null

- block: "Create integration testing worksheet?"
Expand Down
50 changes: 23 additions & 27 deletions .buildkite/setup_and_upload_artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,33 @@

set -euo pipefail

SCRIPTPATH=$(pwd)
PIP_PATH="$SCRIPTPATH/env/bin/pip"
PYTHON_PATH="$SCRIPTPATH/env/bin/python"

echo "Now creating virtualenv..."
virtualenv -p python3.5 env
if [ $? -ne 0 ]; then
echo ".. Abort! Can't create virtualenv."
exit 1
fi

pip install --upgrade "pip < 21.0"
PIP_CMD="$PIP_PATH install -r requirements/release_upload.txt"
echo "Running $PIP_CMD..."
$PIP_CMD
if [ $? -ne 0 ]; then
echo ".. Abort! Can't install '$PIP_CMD'."
exit 1
fi

PYTHON_CMD="$PYTHON_PATH .buildkite/upload_artifacts.py"
echo "Now excuting upload artifacts script..."
echo "--- Downloading all artifacts here for upload to GH"
mkdir -p dist
buildkite-agent artifact download 'dist/*.pex' dist/
buildkite-agent artifact download 'dist/*.whl' dist/
buildkite-agent artifact download 'dist/*.tar.gz' dist/
buildkite-agent artifact download 'dist/*.deb' dist/
buildkite-agent artifact download 'dist/*.exe' dist/

$PYTHON_CMD
if [ $? -ne 0 ]; then
echo ".. Abort! Can't execute '$PYTHON_CMD'."
exit 1
fi
echo "--- Building docker environment in Docker"
# Depends on relevant requirements file and script locations
docker build \
--iidfile upload_artifacts.iid \
-f docker/upload_artifacts.dockerfile \
.

IMAGE=$(cat upload_artifacts.iid)

echo "--- Running script in Docker, image ID: $IMAGE"
# Mounting dist so that we're not redundantly copying
# Adding envars for GH access and Tag information
docker run \
--mount type=bind,src=$PWD/dist,target=/dist \
-e GITHUB_ACCESS_TOKEN \
-e BUILDKITE_TAG \
--cidfile upload_artifacts.cid \
$IMAGE \

CONTAINER=$(cat upload_artifacts.cid)

trap "docker rm $CONTAINER" exit
9 changes: 9 additions & 0 deletions docker/upload_artifacts.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.5-slim-buster

COPY requirements/release_upload.txt .

RUN pip install -r release_upload.txt

COPY .buildkite/upload_artifacts.py .

ENTRYPOINT ["python", "upload_artifacts.py"]