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

Add a new lint pipeline for Python and Terraform #1007

Closed
wants to merge 5 commits into from
Closed
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
1 change: 1 addition & 0 deletions .github/workflows/image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
jupyterlab:
name: 'Build Docker Images'
runs-on: ubuntu-latest
if: "github.repository == 'quansight/qhub'"
strategy:
matrix:
dockerfile:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/kubernetes_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ on:
jobs:
test-kubernetes:
name: "Kubernetes Tests"
if: "github.repository == 'quansight/qhub'"
runs-on: self-hosted
defaults:
run:
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: QHub Lint

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]


jobs:
python-lint:
name: Lint Python code
runs-on: ubuntu-latest
steps:
- name: Checks out the repository
uses: actions/checkout@v3

- name: Sets up Python
uses: actions/setup-python@v2

- name: Checks Black formatting
uses: psf/black@stable

- name: Lints Python code
uses: py-actions/flake8@v2
with:
max-line-length: "89"
path: "qhub"

terraform-lint:
name: Lint Terraform code
runs-on: ubuntu-latest
steps:
- name: Checks out the repository
uses: actions/checkout@v3

- name: Lints Terraform code
uses: actionshub/terraform-lint@main
1 change: 1 addition & 0 deletions .github/workflows/test-provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ env:
jobs:
test-render-providers:
name: 'Test QHub Provider'
if: "github.repository == 'quansight/qhub'"
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
16 changes: 6 additions & 10 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,18 @@ on:
- "setup.cfg"
- "pyproject.yoml"


jobs:
test-general:
name: 'Test Package'
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
steps:
- name: 'Checkout Infrastructure'
uses: actions/checkout@main
Expand All @@ -43,15 +48,6 @@ jobs:
- name: Install QHub
run: |
pip install .[dev]
- name: Black Formatting
run: |
black --version
black qhub --diff --exclude "qhub/_version.py"
black --check qhub --exclude "qhub/_version.py"
- name: Flake8 Formatting
run: |
flake8 --version
flake8
- name: Test QHub
run: |
pytest --version
Expand Down
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![quansight_logo](source/images/qhub_logo.png)

[![Python version](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9-blue.svg)](https://pypi.org/project/qhub/)
[![Python version](https://img.shields.io/badge/python-3.7%20%7C%203.8%20%7C%203.9%20%7C%203.10-blue.svg)](https://pypi.org/project/qhub/)
[![PyPI version](https://badge.fury.io/py/qhub.svg)](https://badge.fury.io/py/qhub)
[![Conda version](https://img.shields.io/badge/conda--forge-v0.3.0-%234f28a8)](https://anaconda.org/conda-forge/qhub)
[![GitHub issues](https://img.shields.io/github/issues/quansight/qhub?style=plastic)](https://github.com/Quansight/qhub/issues/new/choose)
Expand Down
2 changes: 1 addition & 1 deletion qhub/template/stages/01-terraform-state/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module "terraform-state" {
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "3.73.0"
}
}
Expand Down
8 changes: 4 additions & 4 deletions qhub/template/stages/01-terraform-state/azure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ provider "azurerm" {
module "terraform-state" {
source = "./modules/terraform-state"

name = "${var.name}-${var.namespace}"
resource_group_name = var.state_resource_group_name
location = var.region
storage_account_postfix = var.storage_account_postfix
name = "${var.name}-${var.namespace}"
resource_group_name = var.state_resource_group_name
location = var.region
storage_account_postfix = var.storage_account_postfix
}

terraform {
Expand Down
4 changes: 2 additions & 2 deletions qhub/template/stages/01-terraform-state/do/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ provider "digitalocean" {
module "terraform-state" {
source = "./modules/terraform-state"

name = "${var.name }-${var.namespace}"
name = "${var.name}-${var.namespace}"
region = var.region
}

terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
source = "digitalocean/digitalocean"
version = "2.17.0"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
source = "digitalocean/digitalocean"
version = "2.17.0"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
source = "digitalocean/digitalocean"
version = "2.17.0"
}
}
Expand Down
4 changes: 2 additions & 2 deletions qhub/template/stages/01-terraform-state/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ variable "region" {
module "terraform-state" {
source = "./modules/terraform-state"

name = "${var.name }-${var.namespace}"
name = "${var.name}-${var.namespace}"
location = var.region
}

terraform {
required_providers {
google = {
source = "hashicorp/google"
source = "hashicorp/google"
version = "4.8.0"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
output "credentials" {
description = "AWS eks credentials"
sensitive = true
sensitive = true
value = {
endpoint = aws_eks_cluster.main.endpoint
token = data.aws_eks_cluster_auth.main.token
Expand Down
8 changes: 4 additions & 4 deletions qhub/template/stages/02-infrastructure/aws/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
output "kubernetes_credentials" {
description = "Parameters needed to connect to kubernetes cluster"
sensitive = true
value = {
sensitive = true
value = {
host = module.kubernetes.credentials.endpoint
cluster_ca_certificate = module.kubernetes.credentials.cluster_ca_certificate
token = module.kubernetes.credentials.token
Expand All @@ -11,13 +11,13 @@ output "kubernetes_credentials" {
resource "local_file" "kubeconfig" {
count = var.kubeconfig_filename != null ? 1 : 0

content = module.kubernetes.kubeconfig
content = module.kubernetes.kubeconfig
filename = var.kubeconfig_filename
}

output "kubeconfig_filename" {
description = "filename for qhub kubeconfig"
value = var.kubeconfig_filename
value = var.kubeconfig_filename
}

output "nfs_endpoint" {
Expand Down
2 changes: 1 addition & 1 deletion qhub/template/stages/02-infrastructure/aws/versions.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
source = "hashicorp/aws"
version = "3.73.0"
}
}
Expand Down
14 changes: 7 additions & 7 deletions qhub/template/stages/02-infrastructure/azure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ resource "azurerm_resource_group" "resource_group" {


module "registry" {
source = "./modules/registry"
source = "./modules/registry"

name = "${var.name}${var.environment}"
location = var.region
Expand All @@ -16,24 +16,24 @@ module "registry" {
module "kubernetes" {
source = "./modules/kubernetes"

name = "${var.name}-${var.environment}"
environment = var.environment
location = var.region
resource_group_name = azurerm_resource_group.resource_group.name
name = "${var.name}-${var.environment}"
environment = var.environment
location = var.region
resource_group_name = azurerm_resource_group.resource_group.name
# Azure requires that a new, non-existent Resource Group is used, as otherwise
# the provisioning of the Kubernetes Service will fail.
node_resource_group_name = var.node_resource_group_name
kubernetes_version = var.kubernetes_version

node_groups = [
for name, config in var.node_groups: {
for name, config in var.node_groups : {
name = name
auto_scale = true
instance_type = config.instance
min_size = config.min_nodes
max_size = config.max_nodes
}
]
vnet_subnet_id = var.vnet_subnet_id
vnet_subnet_id = var.vnet_subnet_id
private_cluster_enabled = var.private_cluster_enabled
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ resource "azurerm_kubernetes_cluster" "main" {
dns_prefix = "Qhub" # required

# Azure requires that a new, non-existent Resource Group is used, as otherwise the provisioning of the Kubernetes Service will fail.
node_resource_group = var.node_resource_group_name
node_resource_group = var.node_resource_group_name
private_cluster_enabled = var.private_cluster_enabled

kubernetes_version = var.kubernetes_version
default_node_pool {
vnet_subnet_id = var.vnet_subnet_id
vnet_subnet_id = var.vnet_subnet_id
name = var.node_groups[0].name
node_count = 1
vm_size = var.node_groups[0].instance_type
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
output "credentials" {
description = "Credentials required for connecting to kubernetes cluster"
sensitive = true
sensitive = true
value = {
# see bottom of https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster
endpoint = azurerm_kubernetes_cluster.main.kube_config.0.host
Expand All @@ -14,6 +14,6 @@ output "credentials" {

output "kubeconfig" {
description = "Kubernetes connection kubeconfig"
sensitive = true
value = azurerm_kubernetes_cluster.main.kube_config_raw
sensitive = true
value = azurerm_kubernetes_cluster.main.kube_config_raw
}
8 changes: 4 additions & 4 deletions qhub/template/stages/02-infrastructure/azure/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
output "kubernetes_credentials" {
description = "Parameters needed to connect to kubernetes cluster"
sensitive = true
value = {
sensitive = true
value = {
username = module.kubernetes.credentials.username
password = module.kubernetes.credentials.password
client_certificate = module.kubernetes.credentials.client_certificate
Expand All @@ -14,11 +14,11 @@ output "kubernetes_credentials" {
resource "local_file" "kubeconfig" {
count = var.kubeconfig_filename != null ? 1 : 0

content = module.kubernetes.kubeconfig
content = module.kubernetes.kubeconfig
filename = var.kubeconfig_filename
}

output "kubeconfig_filename" {
description = "filename for qhub kubeconfig"
value = var.kubeconfig_filename
value = var.kubeconfig_filename
}
6 changes: 3 additions & 3 deletions qhub/template/stages/02-infrastructure/azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ variable "kubernetes_version" {
variable "node_groups" {
description = "Azure node groups"
type = map(object({
instance = string
min_nodes = number
max_nodes = number
instance = string
min_nodes = number
max_nodes = number
}))
}

Expand Down
8 changes: 4 additions & 4 deletions qhub/template/stages/02-infrastructure/do/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module "kubernetes" {
kubernetes_version = var.kubernetes_version

node_groups = [
for name, config in var.node_groups: {
for name, config in var.node_groups : {
name = name
auto_scale = true
size = config.instance
min_nodes = config.min_nodes
max_nodes = config.max_nodes
size = config.instance
min_nodes = config.min_nodes
max_nodes = config.max_nodes
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "digitalocean_kubernetes_node_pool" "main" {
max_nodes = lookup(local.additional_node_groups[count.index], "max_nodes", 1)

labels = {
"qhub.dev/node_group": local.additional_node_groups[count.index].name
"qhub.dev/node_group" : local.additional_node_groups[count.index].name
}

tags = var.tags
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ output "credentials" {

output "kubeconfig" {
description = "Kubeconfig for connecting to kubernetes cluster"
value = digitalocean_kubernetes_cluster.main.kube_config.0.raw_config
value = digitalocean_kubernetes_cluster.main.kube_config.0.raw_config
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
source = "digitalocean/digitalocean"
version = "2.17.0"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
source = "digitalocean/digitalocean"
version = "2.17.0"
}
}
Expand Down
Loading