From c4108d9697d0718bb28d829cc63f298ac372986b Mon Sep 17 00:00:00 2001 From: Shivam Sandbhor Date: Fri, 11 Dec 2020 12:54:06 +0530 Subject: [PATCH 1/3] Use GH action instead travis for CI. Signed-off-by: Shivam Sandbhor --- .github/workflows/main.yml | 46 ++++++++++++++++++++++++++++++++++++++ .travis.yml | 31 ------------------------- 2 files changed, 46 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/main.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..21601975f --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,46 @@ +name: CI +on: pull_request +jobs: + unit_tests: + runs-on: ubuntu-latest + + services: + # Label used to access the service container + postgres: + image: postgres + env: + POSTGRES_PASSWORD: vulnerablecode + POSTGRES_DB: vulnerablecode + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 + steps: + - name: Check out repository code + uses: actions/checkout@v2 + + - name: Set up Python 3.8 + uses: actions/setup-python@v2 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + sudo apt install python3-dev postgresql libpq-dev build-essential libxml2-dev libxslt1-dev + python -m pip install --upgrade pip + pip install -r requirements.txt + + - name: Run tests + run: pytest + env: + # The hostname, username used to communicate with the PostgreSQL service container + POSTGRES_HOST: localhost + VC_DB_USER: postgres + POSTGRES_PORT: 5432 + DJANGO_DEV: 1 + GH_TOKEN: 1 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0714e1815..000000000 --- a/.travis.yml +++ /dev/null @@ -1,31 +0,0 @@ -language: python -python: 3.8 - -services: - - postgresql - -install: - - pip install -e . -r requirements.txt - -env: - global: - - SECRET_KEY="i1bn=oly)w*2yl-5yc&f!vvgt)p)fh3_2$r#spa!*sw36f5ov7" - - GH_TOKEN="dummygithubtoken" - -before_script: - - psql -c "CREATE DATABASE vulnerablecode;" -U postgres - - ./manage.py migrate - -script: - - ./manage.py collectstatic - - pytest - - pycodestyle --exclude=migrations,settings.py,venv,lib_oval.py,test_ubuntu.py,test_suse.py,test_data_source.py --max-line-length=100 vulnerablecode vulnerabilities - -notifications: - email: false - webhooks: - urls: - - https://webhooks.gitter.im/e/b119fa557626081e1f36 - on_success: change # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: never # options: [always|never|change] default: always From 485b73e2aa9d4066cecf9e464934d3e8de9d07f9 Mon Sep 17 00:00:00 2001 From: Shivam Sandbhor Date: Fri, 11 Dec 2020 13:10:25 +0530 Subject: [PATCH 2/3] Improve CI triggers to run wheneever changes are pushed to PR branch Signed-off-by: Shivam Sandbhor --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 21601975f..61de40e28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,7 @@ name: CI -on: pull_request +on: + pull_request: + types: [opened, synchronize] jobs: unit_tests: runs-on: ubuntu-latest From 6d9a4c8d4246e78ba4621efe421d4f130559b60a Mon Sep 17 00:00:00 2001 From: Shivam Sandbhor Date: Fri, 11 Dec 2020 22:00:51 +0530 Subject: [PATCH 3/3] Readd travis Signed-off-by: Shivam Sandbhor --- .travis.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..f9811e4ed --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +language: python +python: 3.8 + +services: + - postgresql + +install: + - pip install -e . -r requirements.txt + +env: + global: + - SECRET_KEY="i1bn=oly)w*2yl-5yc&f!vvgt)p)fh3_2$r#spa!*sw36f5ov7" + - GH_TOKEN="dummygithubtoken" + +before_script: + - psql -c "CREATE DATABASE vulnerablecode;" -U postgres + - ./manage.py migrate + +script: + - ./manage.py collectstatic + - pytest + - pycodestyle --exclude=migrations,settings.py,venv,lib_oval.py,test_ubuntu.py,test_suse.py,test_data_source.py --max-line-length=100 vulnerablecode vulnerabilities + +notifications: + email: false + webhooks: + urls: + - https://webhooks.gitter.im/e/b119fa557626081e1f36 + on_success: change # options: [always|never|change] default: always + on_failure: always # options: [always|never|change] default: always + on_start: never # options: [always|never|change] default: always \ No newline at end of file