diff --git a/.github/workflows/buildpipeline.yaml b/.github/workflows/ci.yaml similarity index 70% rename from .github/workflows/buildpipeline.yaml rename to .github/workflows/ci.yaml index e8a4745c20..47253d6ab5 100644 --- a/.github/workflows/buildpipeline.yaml +++ b/.github/workflows/ci.yaml @@ -1,25 +1,29 @@ name: CI - on: - push: + push: pull_request: types: [opened, reopened] - concurrency: group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: true - - jobs: Security: name: Security Pipeline uses: uc-cdis/.github/.github/workflows/securitypipeline.yaml@master + with: + python-poetry: 'false' secrets: inherit + UnitTest: + name: Python Unit Test with Postgres + uses: uc-cdis/.github/.github/workflows/python_unit_test.yaml@master + with: + python-version: '3.9' + test-script: 'tests/ci_commands_script.sh' + run-coveralls: true ci: name: Build Image and Push - # TODO Add this line back once we update to Python 3.9 from 3.6 - # needs: Security + needs: Security uses: uc-cdis/.github/.github/workflows/image_build_push.yaml@master secrets: ECR_AWS_ACCESS_KEY_ID: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }} diff --git a/.secrets.baseline b/.secrets.baseline index 52650d108d..e6821355c4 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -124,6 +124,15 @@ "line_number": 17 } ], + ".github/workflows/ci.yaml": [ + { + "type": "Secret Keyword", + "filename": ".github/workflows/ci.yaml", + "hashed_secret": "3e26d6750975d678acb8fa35a0f69237881576b0", + "is_verified": false, + "line_number": 15 + } + ], "deployment/scripts/postgresql/postgresql_init.sql": [ { "type": "Secret Keyword", @@ -386,5 +395,5 @@ } ] }, - "generated_at": "2023-08-08T00:23:28Z" + "generated_at": "2023-09-27T23:07:05Z" } diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 9dfb763ba6..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -language: python -dist: jammy -python: - - "3.9" - -sudo: false - -cache: pip - -services: - - postgresql - -addons: - postgresql: "13" - apt: - sources: - - sourceline: deb http://apt.postgresql.org/pub/repos/apt/ jammy-pgdg main - 13 - key_url: https://www.postgresql.org/media/keys/ACCC4CF8.asc - packages: - - postgresql-13 - -before_install: - # Copy custom configs from the repo because PG-13 isn't set up to run like - # it normally does on Travis out of the box. - # Source: https://github.com/NCI-GDC/psqlgraph/blob/94f315db2c039217752cba85d9c63988f2059317/.travis.yml - - sudo cp travis/postgresql.conf /etc/postgresql/13/main/postgresql.conf - - sudo cp travis/pg_hba.conf /etc/postgresql/13/main/pg_hba.conf - - sudo pg_ctlcluster 13 main restart - -install: - - pip install --upgrade pip - - pip install poetry - - poetry install --all-extras -vv --no-interaction - - poetry show -vv - - psql -c 'SELECT version();' -U postgres - - psql -U postgres -c "create database fence_test_tmp" - - pip list - -before_script: - - sudo rm -f /etc/boto.cfg - - mkdir -p tests/resources/keys; cd tests/resources/keys; openssl genrsa -out test_private_key.pem 2048; openssl rsa -in test_private_key.pem -pubout -out test_public_key.pem - - openssl genrsa -out test_private_key_2.pem 2048; openssl rsa -in test_private_key_2.pem -pubout -out test_public_key_2.pem - - cd - - -script: - - poetry run pytest -vv --cov=fence --cov=migrations/versions --cov-report xml tests - -after_script: - - python-codacy-coverage -r coverage.xml - - COVERALLS_REPO_TOKEN=$COVERALLS_TOKEN coveralls diff --git a/tests/ci_commands_script.sh b/tests/ci_commands_script.sh new file mode 100755 index 0000000000..5ab1d6c6cd --- /dev/null +++ b/tests/ci_commands_script.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +poetry run pytest -vv --cov=fence --cov-report xml tests diff --git a/tests/test-fence-config.yaml b/tests/test-fence-config.yaml index 924766336b..4073a3031b 100755 --- a/tests/test-fence-config.yaml +++ b/tests/test-fence-config.yaml @@ -28,7 +28,7 @@ BASE_URL: 'http://localhost/user' # postgres db to connect to # connection url format: # postgresql://[user[:password]@][netloc][:port][/dbname] -DB: 'postgresql://postgres:postgres@localhost:5432/fence_test_tmp' +DB: 'postgresql://postgres:postgres@localhost:5432/postgres' # A URL-safe base64-encoded 32-byte key for encrypting keys in db # in python you can use the following script to generate one: diff --git a/travis/pg_hba.conf b/travis/pg_hba.conf deleted file mode 100644 index e080219fd3..0000000000 --- a/travis/pg_hba.conf +++ /dev/null @@ -1,10 +0,0 @@ -# This config file will be used for the Travis test run. -# -# The new PostgreSQL 13 changes some settings from what they originally were -# in Travis, so we'll set them back. In particular we want to enable -# passwordless authentication for connections to PostgreSQL. -# Source: https://github.com/NCI-GDC/psqlgraph/blob/94f315db2c039217752cba85d9c63988f2059317/travis/pg_hba.conf -local all postgres trust -local all all trust -host all all 127.0.0.1/32 trust -host all all ::1/128 trust diff --git a/travis/postgresql.conf b/travis/postgresql.conf deleted file mode 100644 index d3959e564b..0000000000 --- a/travis/postgresql.conf +++ /dev/null @@ -1,32 +0,0 @@ -# This config file will be used for PostgreSQL 13 because Travis doesn't -# have configurations set up for it yet. The most important part will be the -# ramfs storage location change. It also defaults to port 5433 so we need to -# change that back, too. -# Copied from https://github.com/NCI-GDC/psqlgraph/blob/94f315db2c039217752cba85d9c63988f2059317/travis/postgresql.conf -data_directory = '/var/ramfs/postgresql/13/main' -hba_file = '/etc/postgresql/13/main/pg_hba.conf' -ident_file = '/etc/postgresql/13/main/pg_ident.conf' -external_pid_file = '/var/run/postgresql/13-main.pid' -port = 5432 -max_connections = 255 -unix_socket_directories = '/var/run/postgresql' -ssl = on -ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem' -ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key' -shared_buffers = 128MB -dynamic_shared_memory_type = posix -max_wal_size = 256MB -min_wal_size = 80MB -log_line_prefix = '%t ' -log_timezone = 'UTC' -cluster_name = '13/main' -stats_temp_directory = '/var/run/postgresql/13-main.pg_stat_tmp' -datestyle = 'iso, mdy' -timezone = 'UTC' -lc_messages = 'en_US.UTF-8' -lc_monetary = 'en_US.UTF-8' -lc_numeric = 'en_US.UTF-8' -lc_time = 'en_US.UTF-8' -default_text_search_config = 'pg_catalog.english' -include_dir = 'conf.d' -fsync = false