Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(travis): remove travis CI, replace with GH Actions #400

Merged
merged 34 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5485cfe
fix(travis): force a reasonable default distribution
Avantol13 Sep 12, 2023
188a644
fix(ci): install postgres
Avantol13 Sep 12, 2023
5bf2b4a
fix(ci): install postgres
Avantol13 Sep 12, 2023
fda307b
feat(gh): try to port unit test to GH Actions
Avantol13 Sep 12, 2023
b3610a2
fix(gh): ensure python commands run in venv
Avantol13 Sep 12, 2023
6deb74e
fix(ci): testing branch
Avantol13 Sep 12, 2023
9834946
chore(whitespace): remove
Avantol13 Sep 13, 2023
b5f79f5
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
da9d968
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
ed82a48
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
0bdf236
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
6ea1f1d
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
84dcc2b
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
372d37c
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
fc0af00
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
809ed5c
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
504e0f1
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
a08b493
fix(tests): update setup of postgres db to support postgres 15 changes
Avantol13 Sep 13, 2023
88ea5d7
fix(tests): update setup of postgres db to support postgres 15 changes
Avantol13 Sep 13, 2023
a5a8402
fix(tests): update setup of postgres db to support postgres 15 changes
Avantol13 Sep 13, 2023
7ec65fa
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
184fe28
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
c86c402
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
9a91f0a
chore(ci): force GH Actions rerun
Avantol13 Sep 13, 2023
719684b
Revert "fix(tests): update setup of postgres db to support postgres 1…
Avantol13 Sep 13, 2023
37054df
fix(ci): ensure exit code is error if any commands error
Avantol13 Sep 13, 2023
dd76ae5
fix(ci): ensure exit code is error if any commands error
Avantol13 Sep 13, 2023
2de6a09
chore(test): cleanup old "integration" tests
Avantol13 Sep 13, 2023
c41892b
chore(ci): add wool, update readme, update setup to defaults
Avantol13 Sep 14, 2023
ec81d18
chore(ci): remove travis
Avantol13 Sep 14, 2023
aedff22
Update ci.yaml
Avantol13 Sep 14, 2023
8010f36
chore(tests): simplify test run script and test failure
Avantol13 Sep 15, 2023
bb43511
Merge remote-tracking branch 'origin/fix/travis' into fix/travis
Avantol13 Sep 15, 2023
52c6b64
chore(tests): remove forced failure used for testing
Avantol13 Sep 15, 2023
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
11 changes: 9 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true


jobs:
Security:
name: Security Pipeline
Expand All @@ -18,7 +17,15 @@ jobs:
python-poetry: 'false'
secrets: inherit

ci:
UnitTest:
name: Python Unit Test with Postgres
uses: uc-cdis/.github/.github/workflows/python_unit_test.yaml@master
with:
setup-script: 'tests/ci_setup.sh'
test-script: 'tests/ci_commands_script.sh'
Comment on lines +24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since these 2 values are the same as the defaults, you could remove them from here, unless you want it to be more explicit where the files are used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I figured since: a) I was gonna use this as an example PR for others to base theirs and b) it's clearer how it's working this way, it'd be better to be explicit

python-version: '3.9'

ImageBuildAndPush:
name: Build Image and Push
uses: uc-cdis/.github/.github/workflows/image_build_push.yaml@master
secrets:
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/wool.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
on:
pull_request

name: Wool

jobs:
runWool:
name: Run black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

- uses: uc-cdis/wool@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48 changes: 0 additions & 48 deletions .travis.yml

This file was deleted.

49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,52 @@ see the README in that folder for more details.

## Submitter ID
Sheepdog requires the `submitter_id` to be unique per node per project. It means that, the `submitter_id` of all `case` nodes must be unique per project. This constraint was technically enforced by the unique index of `(project_id, submitter_id)` in every node table.

## Local Test Run Using CI Scripts

If you want to locally replicate what GH Actions is doing more closely, follow
these steps.

Ensure you've run `poetry install`.

Ensure you have Postgresql 13 set up and running.

Ensure there is a postgres user `postgres` *and* `test` setup with password `test`:

```
CREATE USER postgres WITH PASSWORD 'test';
```

Then run:

```bash
bash tests/ci_setup.sh
```

If the above fails due to postgres errors, your postgresql setup may need some
fixing, it should finish with the following:

```
Setting up test database
Dropping old test data
WARNING:root:Unable to drop test data:(psycopg2.errors.InvalidCatalogName) database "sheepdog_automated_test" does not exist

[SQL: DROP DATABASE "sheepdog_automated_test"]
(Background on this error at: http://sqlalche.me/e/13/f405)
Creating tables in test database
Creating indexes
writing RSA key
```

The WARNING will show up the first time you run this, it's safe to ignore.

That sets up the database so if you run into postgres errors, you'll want to
double check your postgres setup.

After that you can run unit tests with:

```bash
bash tests/ci_commands_script.sh
```

> You can see more detailed information on local dev setup in the docs/local_dev_environment.md
1 change: 0 additions & 1 deletion bin/setup_psqlgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def create_indexes(host, port, user, password, database, use_ssl=False):


if __name__ == "__main__":

parser = argparse.ArgumentParser()
parser.add_argument(
"--host", type=str, action="store", default="localhost", help="psql-server host"
Expand Down
11 changes: 11 additions & 0 deletions tests/ci_commands_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

# since this whole thing is run as a bash {{this script}}, only the last pytest
# command controls the exit code. We actually want to exit early if something fails
set -e

# datadict and datadictwithobjid tests must run separately to allow
# loading different datamodels
poetry run pytest -vv --cov=sheepdog --cov-report xml tests/integration/datadict
poetry run pytest -vv --cov=sheepdog --cov-report xml --cov-append tests/integration/datadictwithobjid
poetry run pytest -vv --cov=sheepdog --cov-report xml --cov-append tests/unit
7 changes: 7 additions & 0 deletions tests/ci_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
poetry run python bin/setup_test_database.py
mkdir -p tests/integration/resources/keys
cd tests/integration/resources/keys
openssl genrsa -out test_private_key.pem 2048
openssl rsa -in test_private_key.pem -pubout -out test_public_key.pem
cd -
10 changes: 10 additions & 0 deletions tests/integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TODO: Why are we integration testing alongside unit tests like this? We need to migrate
these tests elsewhere b/c it's not really integration testing if we're
configuring postgres exactly the way it expects in the CI running this.
Since this CI setup is completely separate from how we run postgres in
production, most of these tests are pointless.

As of 13 SEP 23 I'm ripping out some of this to enable the migration
to Github Actions from Travis CI.

- Alex
6 changes: 1 addition & 5 deletions tests/integration/datadict/test_ssl_and_isolation_level.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copy of a few functional tests in order to test that SSL and isolation level
Copy of a few functional tests in order to test that isolation level
settings work.
"""

Expand All @@ -18,28 +18,24 @@


@pytest.mark.ssl
@pytest.mark.parametrize("use_ssl", USE_SSL, indirect=True)
@pytest.mark.parametrize("isolation_level", ISOLATION_LEVELS, indirect=True)
def test_post_example_entities_together(client, pg_driver, cgci_blgsp, submitter):
do_test_post_example_entities_together(client, submitter)


@pytest.mark.ssl
@pytest.mark.parametrize("use_ssl", USE_SSL, indirect=True)
@pytest.mark.parametrize("isolation_level", ISOLATION_LEVELS, indirect=True)
def test_delete_entity(client, pg_driver, cgci_blgsp, submitter):
do_test_delete_entity(client, submitter)


@pytest.mark.ssl
@pytest.mark.parametrize("use_ssl", USE_SSL, indirect=True)
@pytest.mark.parametrize("isolation_level", ISOLATION_LEVELS, indirect=True)
def test_submit_valid_tsv(client, pg_driver, cgci_blgsp, submitter):
do_test_submit_valid_tsv(client, submitter)


@pytest.mark.ssl
@pytest.mark.parametrize("use_ssl", USE_SSL, indirect=True)
@pytest.mark.parametrize("isolation_level", ISOLATION_LEVELS, indirect=True)
def test_export_all_node_types(
client, pg_driver, cgci_blgsp, submitter, require_index_exists_off
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copy of a few functional tests in order to test that SSL and isolation level
Copy of a few functional tests in order to test that isolation level
settings work.
"""

Expand All @@ -20,28 +20,24 @@


@pytest.mark.ssl
@pytest.mark.parametrize("use_ssl", USE_SSL, indirect=True)
@pytest.mark.parametrize("isolation_level", ISOLATION_LEVELS, indirect=True)
def test_post_example_entities_together(client, pg_driver, cgci_blgsp, submitter):
do_test_post_example_entities_together(client, submitter)


@pytest.mark.ssl
@pytest.mark.parametrize("use_ssl", USE_SSL, indirect=True)
@pytest.mark.parametrize("isolation_level", ISOLATION_LEVELS, indirect=True)
def test_delete_entity(client, pg_driver, cgci_blgsp, submitter):
do_test_delete_entity(client, submitter)


@pytest.mark.ssl
@pytest.mark.parametrize("use_ssl", USE_SSL, indirect=True)
@pytest.mark.parametrize("isolation_level", ISOLATION_LEVELS, indirect=True)
def test_submit_valid_tsv(client, pg_driver, cgci_blgsp, submitter):
do_test_submit_valid_tsv(client, submitter)


@pytest.mark.ssl
@pytest.mark.parametrize("use_ssl", USE_SSL, indirect=True)
@pytest.mark.parametrize("isolation_level", ISOLATION_LEVELS, indirect=True)
def test_export_all_node_types(
client, pg_driver, cgci_blgsp, submitter, require_index_exists_off
Expand Down