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 linting and testing workflow for charts and webapp #4

Merged
merged 7 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
77 changes: 77 additions & 0 deletions .github/check_charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Lint and Test Charts

on:
push:
branches:
- main
- chartsimprovements
tags:
- '*'
paths:
# Only run test and docker publish if some code have changed
- 'deployment/k8s/charts/**'
- '.github/workflows/check_charts.yaml'
pull_request:

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check Version
run: |
current_version=$(grep '^version=' pyproject.toml | cut -f2 -d= | tr -d ' ' | tr -d '"')
app_version=$(grep 'appVersion:' deployment/k8s/charts/Chart.yaml | cut -f2 -d: | tr -d ' ')
if [[ "$current_version" != "$app_version" ]]; then
echo "❌ current version from pyproject.toml ($current_version) and appVersion from Chart.yaml ($app_version) differs";
exit 1;
fi

- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.9.2

- uses: actions/setup-python@v5
with:
python-version: 3.7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
python-version: 3.7
python-version: 3.12


- name: Set up chart-testing
uses: helm/[email protected]

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --chart-dirs deployment/k8s --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "::set-output name=changed::true"
fi

- name: Run chart-testing (lint)
run: ct lint --chart-dirs deployment/k8s --target-branch ${{ github.event.repository.default_branch }}

- name: Build container
uses: docker/build-push-action@v6
if: steps.list-changed.outputs.changed == 'true'
with:
platforms: linux/amd64
context: .
file: dockerfiles/Dockerfile
push: false
tags: "polder:dev"

- name: Create kind cluster
uses: helm/[email protected]
if: steps.list-changed.outputs.changed == 'true'

- name: Load container image in kind cluster
run: kind load docker-image polder:dev --name chart-testing
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: ct install --chart-dirs deployment/k8s
if: steps.list-changed.outputs.changed == 'true'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if: steps.list-changed.outputs.changed == 'true'
if: steps.list-changed.outputs.changed == 'true'

104 changes: 104 additions & 0 deletions .github/workflows/webapp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# This workflow performs basic checks:
#
# 1. run a preparation step to install and cache node modules
# 2. once prep succeeds, run lint and test in parallel
#
# The checks are skipped on the 'main' branch. The project relies on branch
# protection to avoid pushes straight to 'main'.

name: Checks

on:
push:
branches-ignore:
- 'main'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
prep:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Cache node_modules
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Install
run: yarn install

lint:
needs: prep
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Cache node_modules
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Install
run: yarn install
working-directory: ./webapp

- name: Lint
run: yarn lint
working-directory: ./webapp

# Docker container build
build:
needs: prep
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Cache node_modules
uses: actions/cache@v3
id: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Install
run: yarn install
working-directory: ./webapp

- name: Build container
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
context: .
file: dockerfiles/Dockerfile
push: false
tags: "polder:dev"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tags: "polder:dev"
tags: "polder:dev"

6 changes: 6 additions & 0 deletions dockerfiles/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:alpine
WORKDIR /app
COPY webapp/package.json /app
RUN yarn install
COPY webapp/. /app
CMD ["yarn", "run", "start"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CMD ["yarn", "run", "start"]
CMD ["yarn", "run", "start"]

44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[project]
name = "titiler"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name = "titiler"
name = "polder"

description = "A simple web service to create maps and viewer using eoAPI"
readme = "README.md"
requires-python = ">=3.8"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
requires-python = ">=3.8"
requires-python = ">=3.12"

license = {file = "LICENSE"}
authors = [
{name = "Emmanuel Mathot", email = "[email protected]"},
{name = "Ricardo Mestre", email = "[email protected]"},
{name = "Daniel Da Silva", email = "[email protected]"},
{name = "Ciaran Sweet", email = "[email protected]"},
{name = "Olaf Veerman", email = "[email protected]"},
{name = "Felix Delattre", email = "[email protected]"},
]
keywords = [
"COG",
"STAC",
"MosaicJSON",
"Fastapi",
"eoAPI"
]
classifiers = [
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Comment on lines +27 to +30
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",

"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: GIS",
]
version="0.0.1"
dependencies = [
]

[project.urls]
Homepage = 'https://developmentseed.org/polder/'
Documentation = "https://developmentseed.org/polder/"
Issues = "https://github.com/developmentseed/polder/issues"
Source = "https://github.com/developmentseed/polder"
Changelog = "https://developmentseed.org/polder/release-notes/"

Loading