From 9bf5ded01385619190cc3c470d5e921ea60a3b6e Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Thu, 25 Jun 2020 13:50:02 -0400 Subject: [PATCH 1/3] Sync docs to s3 on latest + release --- .github/workflows/main.yml | 15 +++++++++++++++ Makefile | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa02f514..661abf06 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -162,6 +162,21 @@ jobs: with: name: docs path: docs/site/ + - uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET }} + aws-region: us-east-1 + - if: github.event_name == 'push' && github.ref == 'refs/heads/master' + run: make sync-latest-docs-to-s3 + - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.DOCS_AWS_ID }} + aws-secret-access-key: ${{ secrets.DOCS_AWS_SECRET }} + aws-region: us-east-1 + - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') + run: make promote-docs-in-s3 dispatch: if: github.event_name == 'push' && github.ref == 'refs/heads/master' needs: distributions diff --git a/Makefile b/Makefile index 9a06ee98..b1b4f0a9 100644 --- a/Makefile +++ b/Makefile @@ -154,3 +154,15 @@ sync-latest-to-s3: --cache-control max-age=0 \ $(BDIST_WHEEL) \ $(S3_PREFIX)/latest/rsconnect_python-latest-py2.py3-none-any.whl + +.PHONY: sync-latest-docs-to-s3 +sync-latest-docs-to-s3: + aws s3 sync --delete --acl bucket-owner-full-control \ + docs/site/ \ + $(S3_PREFIX)/latest/docs/ + +.PHONY: promote-docs-in-s3 +promote-docs-in-s3: + aws s3 sync --delete --acl bucket-owner-full-control \ + docs/site/ \ + s3://docs.rstudio.com/rsconnect-python/ From 4d1b1821b56dd43c8505276913818b561b70da48 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Thu, 25 Jun 2020 13:59:59 -0400 Subject: [PATCH 2/3] Set appropriate cache-control for docs artifacts --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index b1b4f0a9..8cf83340 100644 --- a/Makefile +++ b/Makefile @@ -158,11 +158,13 @@ sync-latest-to-s3: .PHONY: sync-latest-docs-to-s3 sync-latest-docs-to-s3: aws s3 sync --delete --acl bucket-owner-full-control \ + --cache-control max-age=0 \ docs/site/ \ $(S3_PREFIX)/latest/docs/ .PHONY: promote-docs-in-s3 promote-docs-in-s3: aws s3 sync --delete --acl bucket-owner-full-control \ + --cache-control max-age=300 \ docs/site/ \ s3://docs.rstudio.com/rsconnect-python/ From e9492d17f1d86fb8b2b90b4782da1b00428f0be3 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Thu, 25 Jun 2020 14:21:44 -0400 Subject: [PATCH 3/3] Clean up docs building + embed version and ensure the docs job in Actions has the pythons it needs --- .github/workflows/main.yml | 20 ++++++++++++++++++ Makefile | 5 +++-- README.md | 4 ++++ docs/Dockerfile | 2 +- docs/Makefile | 42 +++++++++++++++++++------------------- docs/mkdocs.yml | 4 ++++ 6 files changed, 53 insertions(+), 24 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 661abf06..88b9159f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -157,6 +157,26 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - run: git fetch --prune --unshallow + - uses: actions/setup-python@v2 + with: + python-version: 3.8.x + - uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: pip-ubuntu-latest-py3.8-${{ hashFiles('Pipfile.lock') }} + restore-keys: | + pip-ubuntu-latest-py3.8-${{ hashFiles('Pipfile.lock') }} + pip-ubuntu-latest-py3.8- + - uses: actions/cache@v1 + with: + path: ~/.local/share/virtualenvs + key: virtualenvs-ubuntu-latest-py3.8-${{ hashFiles('Pipfile.lock') }} + restore-keys: | + virtualenvs-ubuntu-latest-py3.8-${{ hashFiles('Pipfile.lock') }} + virtualenvs-ubuntu-latest-py3.8- + - run: pip install -U pipenv pip + - run: make deps - run: make docs - uses: actions/upload-artifact@v2 with: diff --git a/Makefile b/Makefile index 8cf83340..8658da4c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ VERSION := $(shell pipenv run python setup.py --version) HOSTNAME := $(shell hostname) -BDIST_WHEEL := dist/rsconnect_python-$(VERSION)-py2.py3-none-any.whl S3_PREFIX := s3://rstudio-connect-downloads/connect/rsconnect-python +BDIST_WHEEL := dist/rsconnect_python-$(VERSION)-py2.py3-none-any.whl + RUNNER = docker run \ -it --rm \ -v $(PWD):/rsconnect \ @@ -125,7 +126,7 @@ fmt: fmt-3.8 .PHONY: docs docs: - $(MAKE) -C docs + $(MAKE) -C docs VERSION=$(VERSION) .PHONY: version version: diff --git a/README.md b/README.md index 4e687adc..bdc6d94a 100644 --- a/README.md +++ b/README.md @@ -499,3 +499,7 @@ to enable later redeployment. This data is stored alongside the deployed file, in an `rsconnect-python` subdirectory, if possible. If that location is not writable during deployment, then the deployment data will be stored in the global configuration directory specified above. + +
+Generated from rsconnect-python {{ rsconnect_python.version }} +
diff --git a/docs/Dockerfile b/docs/Dockerfile index 8a02e40a..d20c67d4 100644 --- a/docs/Dockerfile +++ b/docs/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.8.2-alpine3.11 +FROM python:3.8-slim MAINTAINER RStudio Connect # Needed with Python3 mkdocs. diff --git a/docs/Makefile b/docs/Makefile index 31fb8849..6e963f64 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,34 +1,34 @@ -# Our make file for the docs. -MKDOCS_IMAGE?="rstudio/rsconnect:mkdocs" +MKDOCS_IMAGE ?= rstudio/rsconnect:mkdocs +VERSION ?= NOTSET -## Specify that Docker runs with the calling user's uid/gid to avoid file -## permission issues on Linux dev hosts. -DOCKER_RUN_AS= +DOCKER_RUN_AS = ifeq (Linux,$(shell uname)) - DOCKER_RUN_AS=-u $(shell id -u):$(shell id -g) + DOCKER_RUN_AS = -u $(shell id -u):$(shell id -g) endif -BUILD_RUNNER=docker run --rm --name mkdocs \ - ${DOCKER_RUN_AS} \ - -v $(CURDIR):/mkdocs \ - -w /mkdocs \ - ${MKDOCS_IMAGE} +BUILD_RUNNER = \ + docker run --rm --name mkdocs \ + $(DOCKER_RUN_AS) \ + -e VERSION=$(VERSION) \ + -v $(CURDIR):/mkdocs \ + -w /mkdocs \ + $(MKDOCS_IMAGE) -# Do everything, +.PHONY: all all: clean image build -# Destroy the site, if it exists. +.PHONY: clean clean: - @rm -rf docs/site + rm -rf docs/site -# Build the image in which mkdocs will run. +.PHONY: image image: - docker build -t ${MKDOCS_IMAGE} . + docker build -t $(MKDOCS_IMAGE) . -# Build the actual documentation. -build: - python patch_admonitions.py - ${BUILD_RUNNER} mkdocs build +.PHONY: build +build: docs/index.md + $(BUILD_RUNNER) mkdocs build @rm docs/index.md -.PHONY: clean image build +docs/index.md: $(CURDIR)/../README.md + python patch_admonitions.py diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 763eb31e..94cf6eca 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -22,3 +22,7 @@ theme: extra_css: - css/custom.css + +extra: + rsconnect_python: + version: !!python/object/apply:os.getenv ["VERSION"]