Skip to content
Open
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
36 changes: 36 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
61 changes: 3 additions & 58 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pipeline {
//Docker image and runs this image as a separate container. The Python container becomes
//the agent that Jenkins uses to run the Build stage of your Pipeline project.
image 'python:2-alpine'

}
}
steps {
Expand All @@ -20,64 +21,8 @@ pipeline {
//workspace directory for use in later stages.
stash(name: 'compiled-results', includes: 'sources/*.py*')
}
}
stage('Test') {
agent {
docker {
//This image parameter downloads the qnib:pytest Docker image and runs this image as a
//separate container. The pytest container becomes the agent that Jenkins uses to run the Test
//stage of your Pipeline project.
image 'qnib/pytest'
}
}
steps {
//This sh step executes pytest’s py.test command on sources/test_calc.py, which runs a set of
//unit tests (defined in test_calc.py) on the "calc" library’s add2 function.
//The --junit-xml test-reports/results.xml option makes py.test generate a JUnit XML report,
//which is saved to test-reports/results.xml
sh 'py.test --verbose --junit-xml test-reports/results.xml sources/test_calc.py'
}
post {
always {
//This junit step archives the JUnit XML report (generated by the py.test command above) and
//exposes the results through the Jenkins interface.
//The post section’s always condition that contains this junit step ensures that the step is
//always executed at the completion of the Test stage, regardless of the stage’s outcome.
junit 'test-reports/results.xml'
}
}
}
stage('Deliver') {
agent any
//This environment block defines two variables which will be used later in the 'Deliver' stage.
environment {
VOLUME = '$(pwd)/sources:/src'
IMAGE = 'cdrx/pyinstaller-linux:python2'
}
steps {
//This dir step creates a new subdirectory named by the build number.
//The final program will be created in that directory by pyinstaller.
//BUILD_ID is one of the pre-defined Jenkins environment variables.
//This unstash step restores the Python source code and compiled byte
//code files (with .pyc extension) from the previously saved stash. image]
//and runs this image as a separate container.
dir(path: env.BUILD_ID) {
unstash(name: 'compiled-results')

//This sh step executes the pyinstaller command (in the PyInstaller container) on your simple Python application.
//This bundles your add2vals.py Python application into a single standalone executable file
//and outputs this file to the dist workspace directory (within the Jenkins home directory).
sh "docker run --rm -v ${VOLUME} ${IMAGE} 'pyinstaller -F add2vals.py'"
}
}
post {
success {
//This archiveArtifacts step archives the standalone executable file and exposes this file
//through the Jenkins interface.
archiveArtifacts "${env.BUILD_ID}/sources/dist/add2vals"
sh "docker run --rm -v ${VOLUME} ${IMAGE} 'rm -rf build dist'"
}
}


}
}
}
2 changes: 1 addition & 1 deletion sources/add2vals.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''
A simple command line tool that takes 2 values and adds them together using
the calc.py library's 'add2' function.
the calc.py library's 'add2' function. some edits going on
'''

import sys
Expand Down
2 changes: 1 addition & 1 deletion sources/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
them together. If either value is a string (or both of them are) 'add2' ensures
they are both strings, thereby resulting in a concatenated result.
NOTE: If a value submitted to the 'add2' function is a float, it must be done so
in quotes (i.e. as a string).
in quotes (i.e. as a string).hureihvhoj ijrijorij
'''

# If 'value' is not an integer, convert it to a float and failing that, a string.
Expand Down
Empty file added sources/dev/dev
Empty file.
1 change: 1 addition & 0 deletions sources/dev/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hur gkriorh lrijljkhb