Skip to content

Commit

Permalink
Merge branch 'release/2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
al-jeyapal committed Jan 11, 2024
2 parents fc29d4b + 198fda9 commit 74cdab4
Show file tree
Hide file tree
Showing 29 changed files with 476 additions and 92 deletions.
27 changes: 27 additions & 0 deletions .github/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,30 @@ repos:
- id: hadolint-docker
always_run: true
args: ["Dockerfile"]
# Specify `local` to use local pip versions of the pre-commit libs.
- repo: local
hooks:
- id: linter
name: Linter
description: https://github.com/charliermarsh/ruff
entry: .venv/bin/ruff
language: python
files: \.py$
# Ignore lambda functions in `appcli/models/configuration.py::Hooks`.
args: [check, --fix, --ignore, E731]
- id: formatter
name: Formatter
description: https://github.com/charliermarsh/ruff
entry: .venv/bin/ruff
language: python
files: \.py$
args: [format]
# NOTE: Disabling this for now as there is currently no way to exit gracefully when no test are run.
# See https://github.com/pytest-dev/pytest/issues/2393
# - id: pytest
# name: PyTest
# description: https://docs.pytest.org/en/latest/
# entry: .venv/bin/pytest
# language: python
# files: \.py$
# args: []
4 changes: 3 additions & 1 deletion .github/workflows/build_python.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Test Python

on: [push]
on:
push:
workflow_call:

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
branches: [develop]
schedule:
- cron: "36 21 * * 4"
workflow_call:

jobs:
analyze:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/dependabot_test_and_auto_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Dependabot test and auto-merge
on: pull_request

jobs:
# Merge pre-conditions.
test-build-python:
uses: ./.github/workflows/build_python.yml
test-codeql-analysis:
uses: ./.github/workflows/codeql_analysis.yml

# Merge job.
dependabot-auto-merge-workflow:
permissions:
contents: write
pull-requests: write
needs: [test-build-python, test-codeql-analysis]
uses: brightsparklabs/github-actions/.github/workflows/dependabot-auto-merge.yml@master
secrets: inherit
46 changes: 45 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,41 @@ The changelog is applicable from version `1.0.0` onwards.

### Added

- APPCLI-133: Add fix for Git repository ownership issue to the AppCli Dockerfile.
### Fixed

---

## [2.5.0] - 2024-01-11

### Added

- APPCLI-115: Enable automerge for dependabot PRs.
- APPCLI-112: Autovalidate config file when a `.schema.json` file is provided.
- APPCLI-116: Set Ruff as the linter and formatter.
- AF-209: Build the docker-compose plugin into the appcli image.
- DIS-395: Limit the backups to 10 as default.
- AF-210: Stream stdout and stderr.

---

## [2.4.0] - 2023-10-03

### Added

- APED-67: Add support for running `NullOrchestrator` apps on Windows OS.

---

## [2.3.0] - 2023-08-14

### Added

- APPCLI-133: Add fix for Git repository ownership issue to the appcli Dockerfile.

---

## [2.2.1] - 2023-07-24

### Fixed

- APED-37: Prevent quoted arguments with spaces splitting into multiple arguments in the launcher script.
Expand Down Expand Up @@ -284,3 +316,15 @@ and methods, any python referring to the library will need to use full module pa
## [1.0.0] - 2020-10-07

_No changelog for this release._

---

# Template

## [Unreleased]

### Added

### Fixed

---
16 changes: 12 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ FROM alpine:3.15.0 AS docker-binary-download

WORKDIR /tmp

# Download and extract the static docker binary
RUN \
wget -q https://download.docker.com/linux/static/stable/x86_64/docker-20.10.6.tgz \
&& tar xf docker-20.10.6.tgz
# List required versions for docker and compose.
ENV DOCKER_VERSION=24.0.7
ENV DOCKER_COMPOSE_VERSION=2.23.3

# Download docker and compose.
RUN wget -q https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz \
&& tar xf docker-${DOCKER_VERSION}.tgz \
&& wget -q https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64 \
&& wget -q https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64.sha256 \
&& sha256sum -c docker-compose-linux-x86_64.sha256 \
&& chmod +x docker-compose-linux-x86_64

FROM python:3.10.2-slim-bullseye

ENV LANG=C.UTF-8

COPY --from=docker-binary-download /tmp/docker/docker /usr/bin
COPY --from=docker-binary-download /tmp/docker-compose-linux-x86_64 /usr/local/lib/docker/cli-plugins/docker-compose

RUN \
# set timezone to UTC by default
Expand Down
42 changes: 23 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,36 @@ VENV_NAME?=.venv
VENV_ACTIVATE=. $(VENV_NAME)/bin/activate
PYTHON=${VENV_NAME}/bin/python
APP_VERSION=$(shell git describe --always --dirty)
# Format and linter rules to ignore.
# See https://docs.astral.sh/ruff/rules/
RULES=E731

.DEFAULT: help
help:
@echo "make test"
@echo " run tests"
@echo "make lint"
@echo " run flake8"
@echo "make isort"
@echo " run + apply isort"
@echo "make isort-check"
@echo " check with isort"
@echo " run ruff check"
@echo "make lint-check"
@echo " dry-run ruff check"
@echo "make format"
@echo " run + apply black"
@echo " run ruff format"
@echo "make format-check"
@echo " check with black"
@echo " dry-run ruff format"
@echo "make build-wheel"
@echo " build wheel"
@echo "make publish-wheel"
@echo " publish wheel"
@echo "make all"
@echo " run format + isort + lint + test"
@echo " run format + lint + test"
@echo "make docker"
@echo " build docker image"
@echo "make docker-publish"
@echo " publish docker image"
@echo "make check"
@echo " run format-check + isort-check + lint + test"
@echo " run format-check + lint-check + test"
@echo "make precommit"
@echo " manually trigger precommit hooks"

# Requirements are in setup.py, so whenever setup.py is changed, re-run installation of dependencies.
venv: $(VENV_NAME)/bin/activate
Expand All @@ -54,19 +57,17 @@ test: venv
${PYTHON} -m pytest

lint: venv
${PYTHON} -m flake8 --ignore=E501,W503 --exclude=appcli/__init__.py appcli tests
# Ignore lambda functions in `appcli/models/configuration.py::Hooks`.
${PYTHON} -m ruff check --fix --ignore ${RULES} .

isort: venv
${PYTHON} -m isort .

isort-check: venv
${PYTHON} -m isort . --diff --check-only
lint-check: venv
${PYTHON} -m ruff check --ignore ${RULES} .

format: venv
${PYTHON} -m black .
${PYTHON} -m ruff format .

format-check: venv
${PYTHON} -m black . --diff --check
${PYTHON} -m ruff format --check .

clean:
rm -rf build/ dist/ bsl_appcli.egg-info/
Expand All @@ -90,6 +91,9 @@ docker-publish: docker
docker push brightsparklabs/appcli:${APP_VERSION}
docker push brightsparklabs/appcli:latest

all: format isort lint test
all: format lint test

check: format-check lint-check test

check: format-check isort-check lint test
precommit: venv
$(VENV_NAME)/bin/pre-commit run -c .github/.pre-commit-config.yaml
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,32 @@ def main():
- `resources/templates/baseline` - for templates which the end user **is not** expected to modify.
- `resources/templates/configurable` - for templates which the end user is expected to modify.

#### Schema validation

Configuration files will be automatically validated against provided schema files whenever
`configure apply` is run.
Validation is done with [jsonschema](https://json-schema.org/) and is only available for `yaml/yml`
and `json/jsn` files.
The JSON schema file must match the name of the file to validate with a suffix of `.schema.json.`.
It must be placed in the same directory as the file to validate,
The `settings.yml`, `stack_settings.yml` file, and any files in the `resource/templates` or
`resources/overrides` directory can be validated.

```yaml
# resources/templates/configurable/my-config.yml
foobar: 5
```
```json
# resources/templates/configurable/my-config.yml.schema.json
{
"type": "object",
"properties" : {
"foobar" : {"type": "number"}
}
}
```

#### Application context files

Template files are templated with Jinja2. The 'data' passed into the templating engine
Expand Down
6 changes: 6 additions & 0 deletions appcli/commands/configure_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def init(ctx):
logger.debug("Running pre-configure init hook")
hooks.pre_configure_init(ctx)

# Validate the configuration schema.
logger.debug("Validating configuration files")
ConfigurationManager(
cli_context, self.cli_configuration
).validate_configuration()

# Initialise configuration directory
logger.debug("Initialising configuration directory")
ConfigurationManager(
Expand Down
Loading

0 comments on commit 74cdab4

Please sign in to comment.