diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9c02e45aec46bb7378b293d0fd77bccad9f6169d..0977c305e417482febb68d3774444f8067d3709b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,3 +1,7 @@ +stages: + - Build + - Test + # Define environment variables for all stages #variables: # # Tell docker images where the host docker daemon is @@ -26,10 +30,25 @@ # - if: $BUILD_CI_IMAGE # when: always +build_hello_world: + stage: Build +# image: gcc:9 + script: + - gcc -o hello src/hello_world.c + artifacts: + paths: + - hello + # Define stage that builds HTML and uploads the website -python_tests: +tests: + stage: Test image: python:3.8-alpine tags: - ssec_shared script: - - python my_utils.py + - pip install -y pytest pytest-cov + - pytest . + needs: + - job: build_hello_world + artifacts: true + diff --git a/my_utils.py b/my_utils.py index 01205f49e899c8dc4bdf97a2df68696ad5a787c8..8e28df216e555cc52c6b9e09a356b1a89acedfb2 100644 --- a/my_utils.py +++ b/my_utils.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python """Helper methods that aren't actually that helpful. Just an example. diff --git a/src/hello_world.c b/src/hello_world.c index dcfb86bc748e8e6c9f2761df3da40ca4797647e6..03bde36a35d080450098af05d7457ff906e45888 100644 --- a/src/hello_world.c +++ b/src/hello_world.c @@ -1,5 +1,5 @@ #include <stdio.h> int main() { - printf("Hello, World!"); + printf("Hello, World!\n"); return 0; } diff --git a/test.py b/test.py new file mode 100644 index 0000000000000000000000000000000000000000..37b359d362ad01a011ebf23ca6cfbdb87ffd3df2 --- /dev/null +++ b/test.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python +"""Basic tests using pytest.""" + + +def test_hello_world_c(): + import subprocess + bytes_out = subprocess.check_output(['./hello']) + assert bytes_out == b'Hello World!\n' + + +def test_hello_world_py(): + import my_utils + my_utils.print_hello()