Skip to content

Commit cd723f5

Browse files
authored
chore: cleaning (#278)
- Update GitHub Action imports to the latest version. - Update CONTRIBUTING.md to reflect the current development lifecycle. - Update README.md usage instructions. - Refactor `vars.mk`. - Move non-global environment variables from `vars.mk` to their proper locations. - Update environment variable names across the stack to use proper conventions.
1 parent 50e78ac commit cd723f5

File tree

10 files changed

+80
-70
lines changed

10 files changed

+80
-70
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ jobs:
7070
steps:
7171
- uses: actions/checkout@v4
7272
- uses: docker/setup-buildx-action@v3
73-
- run: echo "$CONNECT_LICENSE" > ./integration/license.lic
73+
- name: Write Posit Connect license to disk
74+
run: echo "$CONNECT_LICENSE" > ./integration/license.lic
7475
env:
7576
CONNECT_LICENSE: ${{ secrets.CONNECT_LICENSE }}
7677
- run: make -C ./integration ${{ matrix.CONNECT_VERSION }}

.github/workflows/coverage.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- run: make test
2222
- run: make cov-xml
2323
- if: ${{ ! github.event.pull_request.head.repo.fork }}
24-
uses: orgoro/coverage@v3.1
24+
uses: orgoro/coverage@v3.2
2525
with:
2626
coverageFile: coverage.xml
2727
token: ${{ secrets.GITHUB_TOKEN }}

CONTRIBUTING.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@ Before contributing to the `posit-sdk`, ensure that the following prerequisites
1010

1111
- Python >=3.8
1212

13-
> [!TIP]
14-
> We recommend using virtual environments to maintain a clean and consistent development environment.
13+
> [!INFO]
14+
> We require using virtual environments to maintain a clean and consistent development environment.
15+
> Any Python virtual environment will do.
1516
1617
## Instructions
1718

1819
> [!WARNING]
19-
> Executing `make` will utilize `pip` to install third-party packages in your activated Python environment. Please review the [`Makefile`](./Makefile) to verify behavior before executing any commands.
20+
> Executing `make` will install third-party packages in your Python environment. Please review the [`Makefile`](./Makefile) to verify behavior before executing any commands.
2021
2122
1. Fork the repository and open it in your development environment.
22-
2. Run `make` to run the default development workflow.
23-
3. Make your changes and test them thoroughly using `make test`
24-
4. Run `make fmt` and `make lint` to verify adherence to the project style guide.
25-
5. Commit your changes and push them to your forked repository.
26-
6. Submit a pull request to the main repository.
23+
2. Activate your Python environment (e.g., `source .venv/bin/activate`)
24+
3. Run `make` to run the default development workflow.
25+
4. Make your changes and test them thoroughly using `make test`
26+
5. Run `make fmt` and `make lint` to verify adherence to the project style guide.
27+
6. Commit your changes and push them to your forked repository.
28+
7. Submit a pull request to the main repository.
2729

2830
## Tooling
2931

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test:
6161
$(PYTHON) -m coverage run --source=src -m pytest tests
6262

6363
uninstall: ensure-uv
64-
$(UV) pip uninstall $(NAME)
64+
$(UV) pip uninstall $(PROJECT_NAME)
6565

6666
version:
6767
@$(PYTHON) -m setuptools_scm

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pip install posit-sdk
1212

1313
## Usage
1414

15-
Establish server information and credentials using the following environment variables or when initializing a client. Then checkout some [examples](./examples/0001-overview.qmd) to get started.
15+
Establish server information and credentials using the following environment variables or when initializing a client. Then checkout the [Posit Connect Cookbook](https://docs.posit.co/connect/cookbook/) to get started.
1616

1717
> [!CAUTION]
1818
> It is important to keep your API key safe and secure. Your API key grants access to your account and allows you to make authenticated requests to the Posit API. Treat your API key like a password and avoid sharing it with others. If you suspect that your API key has been compromised, regenerate a new one immediately to maintain the security of your account.
@@ -27,17 +27,27 @@ export CONNECT_SERVER="https://example.com/"
2727
```python
2828
from posit.connect import Client
2929

30-
with Client() as client:
31-
print(client)
30+
client = Client()
3231
```
3332

3433
### Option 2
3534

35+
```shell
36+
export CONNECT_API_KEY="my-secret-api-key"
37+
```
38+
39+
```python
40+
from posit.connect import Client
41+
42+
Client("https://example.com")
43+
```
44+
45+
### Option 3
46+
3647
```python
3748
from posit.connect import Client
3849

39-
with Client(api_key="my-secret-api-key", url="https://example.com") as client:
40-
print(client)
50+
Client("https://example.com", "my-secret-api-key")
4151
```
4252

4353
## Contributing

docs/Makefile

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
11
include ../vars.mk
22

3-
VERSION := $(shell $(MAKE) -C ../ -s version)
3+
# Site settings
4+
PROJECT_VERSION ?= $(shell $(MAKE) -C ../ -s version)
5+
CURRENT_YEAR ?= $(shell date +%Y)
6+
7+
# Quarto settings
8+
QUARTO ?= quarto
9+
QUARTODOC ?= quartodoc
10+
11+
# Netlify settings
12+
NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee
13+
NETLIFY_ARGS :=
14+
ifeq ($(ENV), prod)
15+
NETLIFY_ARGS = --prod
16+
endif
417

518
.DEFAULT_GOAL := all
619

7-
.PHONY: all \
8-
api \
9-
build \
10-
clean \
11-
deps \
12-
preview
20+
.PHONY: all api build clean deps preview deploy
1321

1422
all: deps api build
1523

1624
api:
1725
$(QUARTODOC) build
1826
$(QUARTODOC) interlinks
19-
cp -r _extensions/ reference/_extensions # Required to render footer
27+
cp -r _extensions/ reference/_extensions # Required to render footer
2028

2129
build:
2230
CURRENT_YEAR=$(CURRENT_YEAR) \
23-
VERSION=$(VERSION) \
31+
PROJECT_VERSION=$(PROJECT_VERSION) \
2432
$(QUARTO) render
2533

2634
clean:
@@ -34,7 +42,7 @@ deps:
3442

3543
preview:
3644
CURRENT_YEAR=$(CURRENT_YEAR) \
37-
VERSION=$(VERSION) \
45+
PROJECT_VERSION=$(PROJECT_VERSION) \
3846
$(QUARTO) preview
3947

4048
deploy:

docs/_quarto.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ execute:
55
freeze: auto
66

77
website:
8-
title: "Posit SDK <small>{{< env VERSION >}}</small>"
8+
title: "Posit SDK <small>{{< env PROJECT_VERSION >}}</small>"
99
bread-crumbs: true
1010
favicon: "_extensions/posit-dev/posit-docs/assets/images/favicon.svg"
1111
navbar:
@@ -31,7 +31,7 @@ website:
3131
left: |
3232
Copyright &copy; 2000-{{< env CURRENT_YEAR >}} Posit Software, PBC. All Rights Reserved.
3333
center: |
34-
Posit PRODUCT {{< env VERSION >}}
34+
Posit {{< env PROJECT_VERSION >}}
3535
right:
3636
- icon: question-circle-fill
3737
aria-label: 'Link to Posit Support'

integration/Makefile

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
include ../vars.mk
22

3+
# Docker settings
4+
DOCKER_COMPOSE ?= docker compose
5+
DOCKER_CONNECT_IMAGE ?= rstudio/rstudio-connect
6+
DOCKER_PROJECT_IMAGE_TAG ?= $(PROJECT_NAME):latest
7+
8+
# Connect settings
9+
CONNECT_BOOTSTRAP_SECRETKEY ?= $(shell head -c 32 /dev/random | base64)
10+
311
.DEFAULT_GOAL := all
412

513
.PHONY: $(CONNECT_VERSIONS) \
@@ -57,13 +65,13 @@ latest:
5765
# Run test suite against preview Connect version.
5866
preview:
5967
$(MAKE) \
60-
CONNECT_IMAGE=rstudio/rstudio-connect-preview \
61-
CONNECT_IMAGE_TAG=dev-jammy-daily \
68+
DOCKER_CONNECT_IMAGE=rstudio/rstudio-connect-preview \
69+
DOCKER_CONNECT_IMAGE_TAG=dev-jammy-daily \
6270
down-preview up-preview
6371

6472
# Build Dockerfile
6573
build:
66-
docker build -t $(IMAGE_TAG) ..
74+
docker build -t $(DOCKER_PROJECT_IMAGE_TAG) ..
6775

6876
# Tear down resources.
6977
#
@@ -74,15 +82,15 @@ build:
7482
# make down
7583
# make down-2024.05.0
7684
down: $(CONNECT_VERSIONS:%=down-%)
77-
down-%: CONNECT_IMAGE_TAG=jammy-$*
85+
down-%: DOCKER_CONNECT_IMAGE_TAG=jammy-$*
7886
down-%: CONNECT_VERSION=$*
7987
down-%:
8088
CONNECT_BOOTSTRAP_SECRETKEY=$(CONNECT_BOOTSTRAP_SECRETKEY) \
81-
CONNECT_IMAGE=$(CONNECT_IMAGE) \
82-
CONNECT_IMAGE_TAG=$(CONNECT_IMAGE_TAG) \
89+
DOCKER_CONNECT_IMAGE=$(DOCKER_CONNECT_IMAGE) \
90+
DOCKER_CONNECT_IMAGE_TAG=$(DOCKER_CONNECT_IMAGE_TAG) \
8391
CONNECT_VERSION=$* \
84-
IMAGE_TAG=$(IMAGE_TAG) \
85-
$(DOCKER_COMPOSE) -p $(NAME)-$(subst .,-,$(CONNECT_VERSION)) down -v
92+
DOCKER_PROJECT_IMAGE_TAG=$(DOCKER_PROJECT_IMAGE_TAG) \
93+
$(DOCKER_COMPOSE) -p $(PROJECT_NAME)-$(subst .,-,$(CONNECT_VERSION)) down -v
8694

8795
# Create, start, and run Docker Compose.
8896
#
@@ -92,14 +100,14 @@ down-%:
92100
# make up-2024.05.0
93101
up: $(CONNECT_VERSIONS:%=up-%)
94102
up-%: CONNECT_VERSION=$*
95-
up-%: CONNECT_IMAGE_TAG=jammy-$*
103+
up-%: DOCKER_CONNECT_IMAGE_TAG=jammy-$*
96104
up-%: build
97105
CONNECT_BOOTSTRAP_SECRETKEY=$(CONNECT_BOOTSTRAP_SECRETKEY) \
98-
CONNECT_IMAGE=$(CONNECT_IMAGE) \
99-
CONNECT_IMAGE_TAG=$(CONNECT_IMAGE_TAG) \
106+
DOCKER_CONNECT_IMAGE=$(DOCKER_CONNECT_IMAGE) \
107+
DOCKER_CONNECT_IMAGE_TAG=$(DOCKER_CONNECT_IMAGE_TAG) \
100108
CONNECT_VERSION=$* \
101-
IMAGE_TAG=$(IMAGE_TAG) \
102-
$(DOCKER_COMPOSE) -p $(NAME)-$(subst .,-,$(CONNECT_VERSION)) up -V --abort-on-container-exit --no-build
109+
DOCKER_PROJECT_IMAGE_TAG=$(DOCKER_PROJECT_IMAGE_TAG) \
110+
$(DOCKER_COMPOSE) -p $(PROJECT_NAME)-$(subst .,-,$(CONNECT_VERSION)) up -V --abort-on-container-exit --no-build
103111

104112
# Show help message.
105113
help:

integration/compose.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
tests:
3-
image: ${IMAGE_TAG}
3+
image: ${DOCKER_PROJECT_IMAGE_TAG}
44
# Run integration test suite.
55
#
66
# Target is relative to the ./integration directory, not the project root
@@ -20,7 +20,7 @@ services:
2020
networks:
2121
- test
2222
connect:
23-
image: ${CONNECT_IMAGE}:${CONNECT_IMAGE_TAG}
23+
image: ${DOCKER_CONNECT_IMAGE}:${DOCKER_CONNECT_IMAGE_TAG}
2424
environment:
2525
- CONNECT_BOOTSTRAP_ENABLED=true
2626
- CONNECT_BOOTSTRAP_SECRETKEY=${CONNECT_BOOTSTRAP_SECRETKEY}

vars.mk

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,15 @@
66
# - ./docs/Makefile
77
# - ./integration/Makefile
88

9-
CONNECT_BOOTSTRAP_SECRETKEY ?= $(shell head -c 32 /dev/random | base64)
10-
11-
CONNECT_IMAGE ?= rstudio/rstudio-connect
12-
13-
CURRENT_YEAR ?= $(shell date +%Y)
14-
15-
DOCKER_COMPOSE ?= docker compose
9+
# Shell settings
10+
SHELL := /bin/bash
1611

12+
# Environment settings
1713
ENV ?= dev
1814

19-
IMAGE_TAG ?= $(NAME):latest
20-
21-
NAME := posit-sdk
22-
23-
ifeq ($(ENV), prod)
24-
NETLIFY_ARGS := --prod
25-
else
26-
NETLIFY_ARGS :=
27-
endif
28-
29-
NETLIFY_SITE_ID ?= 5cea1f56-7935-4387-975a-18a7905d15ee
30-
31-
PYTHON := $(shell command -v python || command -v python3)
32-
33-
QUARTO ?= quarto
34-
35-
QUARTODOC ?= quartodoc
36-
37-
SHELL := /bin/bash
15+
# Project settings
16+
PROJECT_NAME := posit-sdk
3817

39-
UV := uv
18+
# Python settings
19+
PYTHON ?= $(shell command -v python || command -v python3)
20+
UV ?= uv

0 commit comments

Comments
 (0)