From 297cfa16f8b6e58e615227c556766aa13e4a61c4 Mon Sep 17 00:00:00 2001 From: Tanner Doshier Date: Tue, 24 Dec 2024 10:29:32 -0500 Subject: [PATCH] WIP CI --- .github/workflows/ci-docker.yml | 26 +++++++++++++ .github/workflows/ci-nix.yml | 69 +++++++++++++++++++++++++++++++++ .github/workflows/ci-pipx.yml | 61 +++++++++++++++++++++++++++++ Makefile | 13 ++++++- 4 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci-docker.yml create mode 100644 .github/workflows/ci-nix.yml create mode 100644 .github/workflows/ci-pipx.yml diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml new file mode 100644 index 0000000..a8ab826 --- /dev/null +++ b/.github/workflows/ci-docker.yml @@ -0,0 +1,26 @@ +name: CI (docker) + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + build-and-run: + name: Build and run + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Build + run: make build + + - name: Run --help + run: docker run --rm nava-platform-cli --help + + - name: Run wrapper + shell: 'script -q -e -c "bash {0}"' + run: ./bin/docker-wrapper infra info ./test-project diff --git a/.github/workflows/ci-nix.yml b/.github/workflows/ci-nix.yml new file mode 100644 index 0000000..6403e73 --- /dev/null +++ b/.github/workflows/ci-nix.yml @@ -0,0 +1,69 @@ +name: CI (nix) + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + # we do this first and make other jobs dependent on this mainly for + # compute-time efficiency, as the other jobs will re-use built artifacts + # pushed to the cache, no need for a bunch of jobs to build the same stuff in + # parallel when a new dependency is added for example + build: + name: Build + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Run build + run: nix build + + lint: + name: Lint + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: DeterminateSystems/flake-checker-action@main + + - name: Run lint + run: nix develop --command bash -c "make check-static" + + test: + name: Test + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Run tests + run: nix develop --command bash -c "make test" + + + install: + name: Install + runs-on: ubuntu-latest + needs: build + + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Run install + run: nix profile install --accept-flake-config '.' + + - name: Run --help + run: nava-platform --help diff --git a/.github/workflows/ci-pipx.yml b/.github/workflows/ci-pipx.yml new file mode 100644 index 0000000..386cd08 --- /dev/null +++ b/.github/workflows/ci-pipx.yml @@ -0,0 +1,61 @@ +name: CI (pip/pipx/native) + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: install poetry + run: pip install poetry + + - name: Install packages + run: make deps + + - name: Run lint + run: make check-static + + test: + name: Test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: install poetry + run: pip install poetry + + - name: Install packages + run: make deps + + - name: Run test + run: make test + + install: + name: Install + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install with pipx + run: pipx install . + + - name: Run --help + run: nava-platform --help diff --git a/Makefile b/Makefile index 7c396d3..1d4e722 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,15 @@ PY_SRCS := nava tests PY_RUN ?= poetry run + +ifdef CI +FMT_ARGS :=--check +LINT_ARGS := +else +FMT_ARGS := +LINT_ARGS :=--fix +endif + build: ## Build docker image docker build --tag $(PKG_NAME) . @@ -30,7 +39,7 @@ deps: ## Install dev dependencies poetry install fmt: ## Run formatter - $(PY_RUN) ruff format $(PY_SRCS) + $(PY_RUN) ruff format $(FMT_ARGS) $(PY_SRCS) lint: ## Run linting lint: lint-mypy lint-ruff lint-poetry @@ -39,7 +48,7 @@ lint-mypy: ## Run mypy $(PY_RUN) mypy $(args) $(PY_SRCS) lint-ruff: ## Run ruff linting with auto-fixes - $(PY_RUN) ruff check --fix $(args) $(PY_SRCS) + $(PY_RUN) ruff check $(LINT_ARGS) $(args) $(PY_SRCS) lint-poetry: ## Run poetry checks poetry check --lock