Skip to content
Closed

D->M #179

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
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
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: docker
directory: "/"
schedule:
interval: weekly
time: '11:00'
open-pull-requests-limit: 10
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
time: '11:00'
open-pull-requests-limit: 10
90 changes: 90 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: KBase Catalog 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:
catalog_tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- python-version: '3.9.19'
mongo-version: '3.6'
- python-version: '3.9.19'
mongo-version: '7.0.4'
services:
mongo:
image: mongo:${{matrix.mongo-version}}
ports:
- 27017:27017
options: --name mongo${{matrix.mongo-version}}

env:
KBASE_CI_TOKEN: ${{ secrets.KBASE_CI_TOKEN }}
# This env var is also used in the catalog test docker compose file for starting NMS
ADMIN_USER: ${{ secrets.KBASE_BOT_USER_CI }}

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

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{matrix.python-version}}

- name: Install dependencies and set up test config
shell: bash

run: |

# test mongo connection
curl http://localhost:27017
returncode=$?
if [ $returncode != 0 ]; then exit $returncode; fi

# set HOMEDIR
export HOMEDIR=`pwd`

# move to parent dir to install binaries etc
cd ..

# setup kb-sdk
mkdir -p $(pwd)/bin
docker run ghcr.io/kbase/kb_sdk_patch-develop:br-0.0.4 genscript > $(pwd)/bin/kb-sdk
chmod 755 $(pwd)/bin/kb-sdk
export PATH=$(pwd)/bin:$PATH

# install catalog dependencies
cd $HOMEDIR
python -m pip install --upgrade pip
pip install pipenv
pipenv sync --system --dev

# setup test config
cp -n test/test.cfg.example test/test.cfg
sed -i "s#^nms-admin-token.*#nms-admin-token=$KBASE_CI_TOKEN#" test/test.cfg
sed -i "s#^method-spec-admin-users.*#method-spec-admin-users=$ADMIN_USER#" test/test.cfg

- name: Run tests
shell: bash
run: make test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
Comment on lines +19 to +90

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 6 months ago

The best way to fix the problem is to add a permissions block at the root level (before jobs:) of the workflow YAML file (.github/workflows/test.yml). This block should specify the least privileges necessary for all jobs in the workflow. From the workflow steps shown, only read access to repository contents is necessary (contents: read). No additional write permissions (for issues, pull-requests, etc.) or access to other scopes appear to be required. This fix should be implemented by inserting the following block immediately after the workflow name (name: KBase Catalog test, line 1) and before the on: block (line 3):

permissions:
  contents: read

No new imports or dependencies are required for this change.

Suggested changeset 1
.github/workflows/test.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,5 +1,8 @@
 name: KBase Catalog test
 
+permissions:
+  contents: read
+
 on:
   pull_request:
     types:
EOF
@@ -1,5 +1,8 @@
name: KBase Catalog test

permissions:
contents: read

on:
pull_request:
types:
Copilot is powered by AI and may make mistakes. Always verify output.
12 changes: 0 additions & 12 deletions .gitmodules

This file was deleted.

40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions DEPENDENCIES

This file was deleted.

30 changes: 24 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
FROM kbase/sdkbase2:python AS build
FROM python:3.9.19 AS build

# The rsync installation is required for the Makefile
RUN apt-get update && apt-get install -y rsync
RUN mkdir -p /kb/deployment/lib/biokbase

COPY . /tmp/catalog
RUN cd /tmp/catalog && make deploy-service deploy-server-control-scripts

FROM kbase/sdkbase2:python
FROM python:3.9.19
# These ARGs values are passed in via the docker build command
ARG BUILD_DATE
ARG VCS_REF
ARG BRANCH

RUN apt-get update && apt-get install -y wget

# install dockerize
WORKDIR /opt
RUN wget -q https://github.com/kbase/dockerize/raw/master/dockerize-linux-amd64-v0.6.1.tar.gz \
&& tar xvzf dockerize-linux-amd64-v0.6.1.tar.gz \
&& rm dockerize-linux-amd64-v0.6.1.tar.gz
RUN mkdir -p /kb/deployment/bin/
RUN ln -s /opt/dockerize /kb/deployment/bin/dockerize

ENV KB_DEPLOYMENT_CONFIG "/kb/deployment/conf/deploy.cfg"

COPY --from=build /kb/deployment/lib/biokbase /kb/deployment/lib/biokbase
COPY --from=build /kb/deployment/services /kb/deployment/services
COPY --from=build /tmp/catalog/deployment/conf /kb/deployment/conf

SHELL ["/bin/bash", "-c"]
COPY requirements.txt requirements.txt
RUN source activate root && \
pip install -r requirements.txt
WORKDIR /tmp/catalog

# install pipenv
RUN pip install --upgrade pip && \
pip install pipenv

# install deps
COPY Pipfile* ./
RUN pipenv sync --system

LABEL org.label-schema.build-date=$BUILD_DATE \
org.label-schema.vcs-url="https://github.com/kbase/catalog.git" \
Expand Down
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ LIB_DIR = lib

PATH := kb_sdk/bin:$(PATH)

default: init

init:
git submodule init
git submodule update

compile-kb-module:
kb-sdk compile $(SPEC_FILE) \
Expand Down Expand Up @@ -102,10 +97,6 @@ setup-tests:
mkdir -p $(TESTLIB)/biokbase
mkdir -p $(TESTDIR)/nms
rsync -av lib/biokbase/* $(TESTLIB)/biokbase/. --exclude *.bak-*
rsync -av kbapi_common/lib/biokbase/* $(TESTLIB)/biokbase/.
cd narrative_method_store; make; make build-classpath-list;
# rsync -av narrative_method_store/lib/biokbase/* $(TESTLIB)/biokbase/.



test: setup-tests
Expand Down
18 changes: 18 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
docker = "==7.1.0"
jsonrpcbase = "==0.2.0"
pymongo = "==4.7.2"
pyyaml = "==6.0.2"
semantic-version = "==2.10.0"
uwsgi = "==2.0.22"

[dev-packages]
coverage = "==7.6.1"

[requires]
python_version = "3.9.19"
Loading