Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/improve-db-sessions
Browse files Browse the repository at this point in the history
Conflicts:
	datagateway_api/src/main.py
	poetry.lock
  • Loading branch information
louise-davies committed Feb 4, 2021
2 parents f67ad95 + 460b680 commit 5f9c318
Show file tree
Hide file tree
Showing 19 changed files with 565 additions and 297 deletions.
8 changes: 4 additions & 4 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ This PR will close #{issue number}
## Description
Enter a description of the changes here

## Testing instructions
## Testing Instructions
Add a set up instructions describing how the reviewer should test the code

- [ ] Review code
- [ ] Check Travis build
- [ ] Check GitHub Actions build
- [ ] Review changes to test coverage
- [ ] {more steps here}

## Agile board tracking
connect to #{issue number}
## Agile Board Tracking
Connect to #{issue number}
157 changes: 157 additions & 0 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
jobs:
tests:
runs-on: ubuntu-16.04
strategy:
fail-fast: false
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
name: Python ${{ matrix.python-version }} Build & Tests
steps:
- name: Add apt repo
run: sudo add-apt-repository universe

# Setup Java & Python
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 8
java-package: jdk
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
architecture: x64

# ICAT Ansible clone and install dependencies
- name: Checkout icat-ansible
uses: actions/checkout@v2
with:
repository: icatproject-contrib/icat-ansible
ref: change-payara-setup-script-url
path: icat-ansible
- name: Install Ansible
run: pip install -r icat-ansible/requirements.txt

# Prep for running the playbook
- name: Create hosts file
run: echo -e "[icatdb-minimal-hosts]\nlocalhost ansible_connection=local" > icat-ansible/hosts
- name: Prepare vault pass
run: echo -e "icattravispw" > icat-ansible/vault_pass.txt
- name: Move vault to directory it'll get detected by Ansible
run: mv icat-ansible/vault.yml icat-ansible/group_vars/all
- name: Replace default payara user with Actions user
run: |
sed -i -e "s/^payara_user: \"glassfish\"/payara_user: \"runner\"/" icat-ansible/group_vars/all/vars.yml
# Create local instance of ICAT
- name: Run ICAT Ansible Playbook
run: |
ansible-playbook icat-ansible/icatdb-minimal-hosts.yml -i icat-ansible/hosts --vault-password-file icat-ansible/vault_pass.txt -vv
- name: Checkout DataGateway API
uses: actions/checkout@v2
with:
path: datagateway-api

# Prep for using the API for tests
- name: Create log file
run: touch logs.log
- name: Configure log file location
run: echo "`jq -r --arg REPO_DIR "$GITHUB_WORKSPACE/logs.log" \
'.log_location=$REPO_DIR' datagateway-api/config.json.example`" > datagateway-api/config.json.example
- name: Create config.json
run: cp datagateway-api/config.json.example datagateway-api/config.json

# Install Nox, Poetry and API's dependencies
- name: Install Nox
run: pip install nox==2020.8.22
- name: Install Poetry
run: pip install poetry==1.1.4
- name: Install dependencies
run: cd datagateway-api/ && poetry install

- name: Add dummy data to icatdb
run: |
cd datagateway-api && poetry run python -m util.icat_db_generator -s 4 -y 3
# Run Nox tests session, saves and uploads a coverage report to codecov
- name: Run Nox tests session
run: nox -s tests -f datagateway-api/noxfile.py -- --cov=datagateway_api --cov-report=xml
- name: Upload code coverage report
if: matrix.python-version == '3.6'
uses: codecov/codecov-action@v1
with:
directory: ./datagateway-api

linting:
runs-on: ubuntu-16.04
name: Linting
steps:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.6'
architecture: x64
- name: Checkout DataGateway API
uses: actions/checkout@v2
with:
path: datagateway-api

- name: Install Nox
run: pip install nox==2020.8.22
- name: Install Poetry
run: pip install poetry==1.1.4

- name: Run Nox lint session
run: nox -s lint -f datagateway-api/noxfile.py

formatting:
runs-on: ubuntu-16.04
name: Code Formatting
steps:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.6'
architecture: x64
- name: Checkout DataGateway API
uses: actions/checkout@v2
with:
path: datagateway-api

- name: Install Nox
run: pip install nox==2020.8.22
- name: Install Poetry
run: pip install poetry==1.1.4

- name: Run Nox black session
run: nox -s black -f datagateway-api/noxfile.py

safety:
runs-on: ubuntu-16.04
name: Dependency Safety
steps:
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.6'
architecture: x64
- name: Checkout DataGateway API
uses: actions/checkout@v2
with:
path: datagateway-api

- name: Install Nox
run: pip install nox==2020.8.22
- name: Install Poetry
run: pip install poetry==1.1.4

- name: Run Nox safety session
run: nox -s safety -f datagateway-api/noxfile.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ config.json
.nox/
.python-version
.coverage
coverage.xml
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[![Build Status](https://github.com/ral-facilities/datagateway-api/workflows/CI/badge.svg?branch=master)](https://github.com/ral-facilities/datagateway-api/actions?query=workflow%3A%22CI%22)
[![Codecov](https://codecov.io/gh/ral-facilities/datagateway-api/branch/master/graph/badge.svg)](https://codecov.io/gh/ral-facilities/datagateway-api)



# DataGateway API
This is a Flask-based API that fetches data from an ICAT instance, to interface with
[DataGateway](https://github.com/ral-facilities/datagateway). This API uses two ways
Expand Down Expand Up @@ -90,6 +95,7 @@ version needs to be downloaded and built individually:
pyenv install 3.6.8
pyenv install 3.7.7
pyenv install 3.8.2
pyenv install 3.9.0
```

To verify the installation commands worked:
Expand All @@ -98,6 +104,7 @@ To verify the installation commands worked:
python3.6 --version
python3.7 --version
python3.8 --version
python3.9 --version
```

These Python versions need to be made available to local version of the repository. They
Expand All @@ -106,7 +113,7 @@ following command will create a `.python-version` file inside the repo (this fil
currently listed in `.gitignore`):

```bash
pyenv local 3.6.8 3.7.7 3.8.2
pyenv local 3.6.8 3.7.7 3.8.2 3.9.0
```


Expand Down
6 changes: 3 additions & 3 deletions config.json.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"backend": "db",
"DB_URL": "mysql+pymysql://root:rootpw@localhost:13306/icatdb",
"ICAT_URL": "https://localhost.localdomain:8181",
"DB_URL": "mysql+pymysql://icatdbuser:icatdbuserpw@localhost:3306/icatdb",
"ICAT_URL": "https://localhost:8181",
"icat_check_cert": false,
"log_level": "WARN",
"log_location": "/home/user1/datagateway-api/logs.log",
"log_location": "/home/runner/work/datagateway-api/datagateway-api/logs.log",
"debug_mode": false,
"generate_swagger": false,
"host": "127.0.0.1",
Expand Down
1 change: 0 additions & 1 deletion datagateway_api/common/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

class Constants:
DATABASE_URL = config.get_db_url()
ACCEPTED_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"
PYTHON_ICAT_DISTNCT_CONDITION = "!= null"
ICAT_PROPERTIES = config.get_icat_properties()
TEST_MOD_CREATE_DATETIME = datetime(2000, 1, 1)
Loading

0 comments on commit 5f9c318

Please sign in to comment.