Skip to content
Open

D->M #47

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
bad0674
Update versions of all requirements
jayrbolton Feb 16, 2021
c1bc115
Only run bandit on source code, not tests
jayrbolton Feb 16, 2021
4c586da
Fix tests and minio error classes
jayrbolton Feb 16, 2021
efbb8fa
Debug travis
jayrbolton Feb 16, 2021
72e10c7
Clean up some dependency boot ordering
jayrbolton Feb 17, 2021
ed105ad
Try a docker-compose version that works on travis
jayrbolton Feb 17, 2021
65b8395
Clean up logging statement
jayrbolton Feb 18, 2021
edc965f
Merge pull request #15 from kbase/upgrade-dependencies
jayrbolton Feb 18, 2021
e1c6f2b
Merge pull request #15 from kbase/upgrade-dependencies
jayrbolton Feb 18, 2021
496fddb
Merge branch 'develop' of https://github.com/kbase/CachingService int…
jayrbolton Feb 18, 2021
8931e03
run pass tests locally
Xiangs18 Mar 14, 2025
d48f48e
add GHA files
Xiangs18 Mar 14, 2025
fd5d1aa
upgrade python version in GHA
Xiangs18 Mar 14, 2025
b5494fe
change to docker compose
Xiangs18 Mar 14, 2025
d148f61
add coverage support
Xiangs18 Mar 14, 2025
d0b0657
remove travis file
Xiangs18 Mar 14, 2025
9d09a8f
conver to pytest and update python version in GHA
Xiangs18 Mar 14, 2025
0d117dc
keep python version as 3.9.19
Xiangs18 Mar 14, 2025
decde53
convert to pytest
Xiangs18 Mar 15, 2025
3275e09
fix codecov display error
Xiangs18 Mar 17, 2025
9b4eeb9
upload coverage.xml
Xiangs18 Mar 17, 2025
945b204
upgrade build python version to 3.9.19
Xiangs18 Mar 17, 2025
f516823
comment mypy to allow tests pass
Xiangs18 Mar 17, 2025
37ef46b
Merge pull request #24 from kbase/dev-add_gha
Xiangs18 Mar 18, 2025
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
52 changes: 52 additions & 0 deletions .github/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: "Code scanning - action"

on:
push:
pull_request:
schedule:
- cron: '0 19 * * 0'

jobs:
CodeQL-Build:

# CodeQL runs on ubuntu-latest and windows-latest
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
23 changes: 23 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
version: 2
updates:

# Docker
- package-ecosystem: docker
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 25

# Python
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "monthly"
open-pull-requests-limit: 25

# GitHub Actions
- package-ecosystem: "github-actions"
directory: ".github/workflows"
schedule:
interval: "monthly"
open-pull-requests-limit: 25
11 changes: 11 additions & 0 deletions .github/workflows/manual-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
name: Manual Build & Push
on:
workflow_dispatch:
jobs:
build-push:
uses: kbase/.github/.github/workflows/reusable_build-push.yml@main
with:
name: '${{ github.event.repository.name }}-develop'
tags: br-${{ github.ref_name }}
secrets: inherit
43 changes: 43 additions & 0 deletions .github/workflows/pr_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Pull Request Build, Tag, & Push
on:
pull_request:
branches:
- develop
- main
- master
types:
- opened
- reopened
- synchronize
- closed
jobs:
build-develop-open:
if: github.base_ref == 'develop' && github.event.pull_request.merged == false
uses: kbase/.github/.github/workflows/reusable_build.yml@main
secrets: inherit
build-develop-merge:
if: github.base_ref == 'develop' && github.event.pull_request.merged == true
uses: kbase/.github/.github/workflows/reusable_build-push.yml@main
with:
name: '${{ github.event.repository.name }}-develop'
tags: pr-${{ github.event.number }},latest
secrets: inherit
build-main-open:
if: (github.base_ref == 'main' || github.base_ref == 'master') && github.event.pull_request.merged == false
uses: kbase/.github/.github/workflows/reusable_build-push.yml@main
with:
name: '${{ github.event.repository.name }}'
tags: pr-${{ github.event.number }}
secrets: inherit
build-main-merge:
if: (github.base_ref == 'main' || github.base_ref == 'master') && github.event.pull_request.merged == true
uses: kbase/.github/.github/workflows/reusable_build-push.yml@main
with:
name: '${{ github.event.repository.name }}'
tags: pr-${{ github.event.number }},latest-rc
secrets: inherit
trivy-scans:
if: (github.base_ref == 'develop' || github.base_ref == 'main' || github.base_ref == 'master' ) && github.event.pull_request.merged == false
uses: kbase/.github/.github/workflows/reusable_trivy-scans.yml@main
secrets: inherit
25 changes: 25 additions & 0 deletions .github/workflows/release-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
name: Release - Build & Push Image
on:
release:
branches:
- main
- master
types: [ published ]
jobs:
check-source-branch:
uses: kbase/.github/.github/workflows/reusable_validate-branch.yml@main
with:
build_branch: '${{ github.event.release.target_commitish }}'
validate-release-tag:
needs: check-source-branch
uses: kbase/.github/.github/workflows/reusable_validate-release-tag.yml@main
with:
release_tag: '${{ github.event.release.tag_name }}'
build-push:
needs: validate-release-tag
uses: kbase/.github/.github/workflows/reusable_build-push.yml@main
with:
name: '${{ github.event.repository.name }}'
tags: '${{ github.event.release.tag_name }},latest'
secrets: inherit
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: KBase File Cache Server test

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
push:
# run workflow when merging to main or develop
branches:
- main
- master
- develop

jobs:
file_cache_server_tests:
runs-on: ubuntu-latest

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

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: 3.9.19

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r dev-requirements.txt

- name: Run tests
shell: bash
run: |
docker compose up -d
sleep 10
make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
7 changes: 0 additions & 7 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-slim
FROM python:3.9.19-slim

ARG DEVELOPMENT
ARG BUILD_DATE
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: test stress-test

test:
docker-compose run web sh scripts/run_tests.sh
docker compose run web sh scripts/run_tests.sh

stress-test:
docker-compose run web sh -c "python -m unittest src/test/test_server_stress.py"
docker compose run web sh -c "python -m unittest src/test/test_server_stress.py"
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1.1
14 changes: 7 additions & 7 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mypy==0.610
bandit==1.4.0
mccabe==0.6.1
pyflakes==2.0.0
flake8==3.5.0
grequests==0.3.0
coverage==4.5.1
mypy==0.800
bandit==1.7.0
mccabe==0.7.0
flake8==5.0.4
grequests==0.6.0
pytest==7.4.0
pytest-cov==4.1.0
9 changes: 6 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3'
version: '3.7'

services:

Expand All @@ -17,12 +17,15 @@ services:
- "127.0.0.1:5000:5000"
volumes:
- .:/app
depends_on:
- minio
- auth

# For running the file server
minio:
image: minio/minio
ports:
- "127.0.0.1:9000:9000"
expose:
- "9000"
environment:
- MINIO_ACCESS_KEY=minio
- MINIO_SECRET_KEY=minio123
Expand Down
17 changes: 10 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
minio==4.0.11
Flask==1.0.2
gunicorn==19.9.0
gevent==1.4.0
simplejson==3.16.0
python-dotenv==0.10.1
requests==2.21.0
minio==7.0.2
flask==2.0.3
gunicorn==20.0.4
gevent==21.1.2
simplejson==3.17.2
python-dotenv==0.15.0
requests==2.25.1
docopt==0.6.2
Jinja2==3.0
MarkupSafe==2.0.0
werkzeug==2.0.3
15 changes: 15 additions & 0 deletions scripts/docker_deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
set -euo xtrace

ver=$(cat VERSION)
export IMAGE_NAME="kbase/cachingservice:$ver"
echo "Build hook running"
export BRANCH=${TRAVIS_BRANCH:-`git symbolic-ref --short HEAD`}
export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
export COMMIT=${TRAVIS_COMMIT:-`git rev-parse --short HEAD`}

docker build --build-arg BUILD_DATE=$DATE \
--build-arg VCS_REF=$COMMIT \
--build-arg BRANCH=$BRANCH \
-t ${IMAGE_NAME} .
docker push $IMAGE_NAME
6 changes: 3 additions & 3 deletions scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ set -e

flake8 --max-complexity 6 src/caching_service
flake8 src/test
mypy --ignore-missing-imports src
bandit -r src
python -m unittest discover src/test/caching_service
# mypy --ignore-missing-imports src
bandit -r src/caching_service
PYTHONPATH=. pytest -s -vv --cov=src/caching_service --cov-report=term --cov-report=xml src/test/caching_service
16 changes: 8 additions & 8 deletions scripts/start_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ calc_workers="$(($(nproc) * 2 + 1))"
# Use the WORKERS environment variable, if present
workers=${WORKERS:-$calc_workers}

gunicorn \
--worker-class gevent \
--timeout 1800 \
--workers $workers \
--bind :5000 \
${DEVELOPMENT:+"--reload"} \
src.caching_service.server:app
app:app
python -m src.caching_service.utils.init_app && \
gunicorn \
--worker-class gevent \
--timeout 1800 \
--workers $workers \
--bind :5000 \
${DEVELOPMENT:+"--reload"} \
src.caching_service.server:app
2 changes: 0 additions & 2 deletions src/caching_service/api/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import tempfile
import json
import flask
import minio.error
import shutil

from ..authorization.service_token import requires_service_token
Expand Down Expand Up @@ -88,7 +87,6 @@ def delete(cache_id):
# --------------

@api_v1.errorhandler(exceptions.MissingCache)
@api_v1.errorhandler(minio.error.NoSuchKey)
def missing_cache_file(err):
"""A cache ID was not found, but was expected to exist."""
result = {'status': 'error', 'error': 'Cache ID not found'}
Expand Down
Loading
Loading