Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Commit 70c3251

Browse files
authored
Merge pull request #4 from CSCfi/feature/github-actions
Move to GitHub actions
2 parents 4a30fce + 67cf175 commit 70c3251

File tree

6 files changed

+105
-5
lines changed

6 files changed

+105
-5
lines changed

.github/workflows/publish.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish Docker image
2+
3+
on:
4+
release:
5+
types: [published]
6+
push:
7+
branches: [master, devel]
8+
9+
jobs:
10+
push_to_registry:
11+
name: Push swift upload runner Docker image to Docker Hub
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v1
15+
- name: Login to DockerHub Registry
16+
run: echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin
17+
- name: Get the version
18+
id: vars
19+
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
20+
- name: Build the tagged Docker image
21+
if: ${{ steps.vars.outputs.tag != '/master' && steps.vars.outputs.tag != '/devel' }}
22+
run: docker build . --file Dockerfile --tag cscfi/swift-upload-runner:${{steps.vars.outputs.tag}}
23+
- name: Push the tagged Docker image
24+
if: ${{ steps.vars.outputs.tag != '/master' && steps.vars.outputs.tag != '/devel' }}
25+
run: docker push cscfi/swift-upload-runner:${{steps.vars.outputs.tag}}
26+
- name: Build the latest Docker image
27+
if: ${{ steps.vars.outputs.tag == '/master' }}
28+
run: docker build . --file Dockerfile --tag cscfi/swift-upload-runner:latest
29+
- name: Push the latest Docker image
30+
if: ${{ steps.vars.outputs.tag == '/master' }}
31+
run: docker push cscfi/swift-upload-runner:latest
32+
- name: Build the stage Docker image
33+
if: ${{ steps.vars.outputs.tag == '/devel' }}
34+
run: docker build . --file Dockerfile --tag cscfi/swift-upload-runner:stage
35+
- name: Push the stage Docker image
36+
if: ${{ steps.vars.outputs.tag == '/devel' }}
37+
run: docker push cscfi/swift-upload-runner:stage

.github/workflows/style.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Python style check
2+
3+
on: [push]
4+
5+
jobs:
6+
style_check:
7+
strategy:
8+
max-parallel: 4
9+
matrix:
10+
os: [ubuntu-latest]
11+
python-version: [3.7]
12+
13+
runs-on: ${{ matrix.os }}
14+
15+
steps:
16+
- uses: actions/checkout@v1
17+
- name: Set up Python ${{ matrix.python-version }}
18+
uses: actions/setup-python@v1
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install tox tox-gh-actions
25+
- name: Test flake8 syntax with tox
26+
run: tox -e flake8
27+
- name: bandit static check
28+
run: tox -e bandit

swift_upload_runner/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_session_id(
5656
def get_auth_instance(
5757
request: aiohttp.web.Request
5858
) -> keystoneauth1.session.Session:
59-
"""Return the session specific keystone auth instance"""
59+
"""Return the session specific keystone auth instance."""
6060
return request.app[get_session_id(request)]["auth"]
6161

6262

swift_upload_runner/download.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ def __init__(
305305
container: str,
306306
chunk_size=128 * 1024
307307
):
308+
"""."""
308309
self.auth = auth
309310
self.download_queue: queue.Queue = queue.Queue(
310311
maxsize=3
@@ -384,9 +385,7 @@ def _parse_archive_fs(
384385
[i[1:] for i in dir_contents],
385386
get_path_from_list(
386387
[path[0]],
387-
path_prefix
388-
)
389-
)
388+
path_prefix))
390389
}
391390
# Path of == 1 implies a file
392391
else:
@@ -440,6 +439,7 @@ def sync_folders(
440439
def download_init(
441440
self,
442441
):
442+
"""Create download init."""
443443
self.download_init_loop(self.fs)
444444
self.download_queue.put(None)
445445

swift_upload_runner/replicate.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async def a_generate_object_from_reader(
6363
break
6464
yield chunk
6565
number += 1
66-
LOGGER.debug(f"Response stream complete.")
66+
LOGGER.debug("Response stream complete.")
6767

6868
async def a_create_container(
6969
self,

tox.ini

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[tox]
2+
envlist = flake8, bandit, pytest
3+
skipdist = True
4+
5+
[testenv:bandit]
6+
skip_install = True
7+
deps = bandit
8+
commands = bandit -r ./swift_upload_runner
9+
10+
[flake8]
11+
ignore = W503,D203,D212,D100,D104
12+
13+
[testenv:flake8]
14+
skip_install = True
15+
deps =
16+
flake8
17+
flake8-docstrings
18+
commands = flake8 .
19+
20+
[testenv:pytest]
21+
deps =
22+
.[test]
23+
-rrequirements.txt
24+
commands = py.test -x --cov=swift_upload_runner tests
25+
; add later
26+
; --cov-fail-under=75
27+
28+
[testenv]
29+
deps =
30+
-rrequirements.txt
31+
32+
[gh-actions]
33+
python =
34+
3.6: pytest
35+
3.7: flake8, pytest, bandit

0 commit comments

Comments
 (0)