88 pull_request :
99 branches : main
1010
11- env :
12- CKANVERSION : 2.9
13-
1411jobs :
1512 code_quality :
1613 runs-on : ubuntu-latest
1714 steps :
18- - uses : actions/checkout@v2
15+ - uses : actions/checkout@v4
1916
2017 - name : Setup Python
21- uses : actions/setup-python@v2
18+ uses : actions/setup-python@v4
2219 with :
23- python-version : ' 3.8 '
20+ python-version : ' 3.10 '
2421
2522 - name : Install flake8
2623 run : |
@@ -29,107 +26,83 @@ jobs:
2926
3027 - name : Lint with flake8
3128 run : |
32- flake8 . --count --max-complexity=12 --max-line-length=127 --statistics --exclude ckan,ckanext-s3filestore
29+ flake8 . --count --max-complexity=13 --max-line-length=127 --statistics
3330
3431 test :
35- runs-on : ubuntu-latest
3632 strategy :
3733 matrix :
38- python-version : [ '3.8' ]
39- name : Python ${{ matrix.python-version }} extension test
34+ python-version : ["3.9", "3.10"]
35+ ckan-version : ["2.10", "2.11"]
36+ fail-fast : false
4037
38+ name : CKAN ${{ matrix.ckan-version }} Python ${{ matrix.python-version }}
39+ runs-on : ubuntu-latest
40+ container :
41+ image : ckan/ckan-dev:${{ matrix.ckan-version }}
42+ options : --user root
4143 services :
42- postgresql :
43- image : postgres
44+ solr :
45+ image : ckan/ckan-solr:${{ matrix.ckan-version }}-solr9
46+ postgres :
47+ image : ckan/ckan-postgres-dev:${{ matrix.ckan-version }}
4448 env :
49+ POSTGRES_USER : postgres
4550 POSTGRES_PASSWORD : postgres
51+ POSTGRES_DB : postgres
4652 options : >-
4753 --health-cmd pg_isready
4854 --health-interval 10s
4955 --health-timeout 5s
5056 --health-retries 5
51- ports :
52- - 5432:5432
53-
5457 redis :
55- image : redis
58+ image : redis:3
59+ moto :
60+ image : motoserver/moto:latest
61+ ports :
62+ - 9000:5000
5663 options : >-
57- --health-cmd "redis-cli ping "
58- --health-interval 10s
59- --health-timeout 5s
64+ --health-cmd "curl -f http://localhost:5000 || exit 1 "
65+ --health-interval 5s
66+ --health-timeout 2s
6067 --health-retries 5
61- ports :
62- - 6379:6379
6368
64- ckan-solr :
65- # Workflow level env variables are not addressable on job level, only on steps level
66- # image: ghcr.io/keitaroinc/ckan-solr-dev:{{ env.CKANVERSION }}
67- image : ghcr.io/keitaroinc/ckan-solr-dev:2.9
68- ports :
69- - 8983:8983
69+ env :
70+ CKAN_SQLALCHEMY_URL : postgresql://ckan_default:pass@postgres/ckan_test
71+ CKAN_DATASTORE_WRITE_URL : postgresql://datastore_write:pass@postgres/datastore_test
72+ CKAN_DATASTORE_READ_URL : postgresql://datastore_read:pass@postgres/datastore_test
73+ CKAN_SOLR_URL : http://solr:8983/solr/ckan
74+ CKAN_REDIS_URL : redis://redis:6379/1
75+ CKANEXT_S3FILESTORE__HOST_NAME : http://moto:5000
76+ AWS_ACCESS_KEY_ID : test-access-key
77+ AWS_SECRET_ACCESS_KEY : test-secret-key
78+ AWS_DEFAULT_REGION : us-east-1
7079
7180 steps :
72- - uses : actions/checkout@v2
73-
74- - name : Setup Python
75- uses : actions/setup-python@v2
76- with :
77- python-version : ${{ matrix.python-version }}
78- architecture : x64
81+ - uses : actions/checkout@v4
7982
80- - name : Install pytest
83+ - name : Install requirements
8184 run : |
82- python -m pip install --upgrade pip
83- pip install pytest
85+ pip install -e .
86+ pip install boto3
87+ # Replace default path to CKAN core config file with the one on the container
88+ sed -i -e 's/use = config:.*/use = config:\/srv\/app\/src\/ckan\/test-core.ini/' test.ini
8489
85- - name : Setup CKAN
86- env :
87- PGPASSWORD : postgres
90+ - name : Create S3 bucket in Moto
8891 run : |
89- bash bin/setup-ckan.bash
92+ python - <<'EOF'
93+ import boto3, os
94+ s3 = boto3.client(
95+ "s3",
96+ endpoint_url=os.environ["CKANEXT_S3FILESTORE__HOST_NAME"],
97+ aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
98+ aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
99+ region_name=os.environ["AWS_DEFAULT_REGION"],
100+ )
101+ s3.create_bucket(Bucket="test-bucket")
102+ print("✅ Created test-bucket in Moto")
103+ EOF
104+
105+ - name : Run all tests
106+ run : pytest --ckan-ini=test.ini --disable-warnings ckanext/s3filestore/tests
90107
91- - name : Test with pytest
92- run : |
93- pytest --ckan-ini=subdir/test.ini --cov=ckanext.s3filestore --disable-warnings ckanext/s3filestore/tests
94108
95- - name : Coveralls
96- uses : AndreMiras/coveralls-python-action@develop
97- with :
98- parallel : true
99- flag-name : Python ${{ matrix.python-version }} Unit Test
100-
101- publish :
102- needs : test
103- runs-on : ubuntu-latest
104- steps :
105- - uses : actions/checkout@v2
106-
107- - name : Setup Python
108- uses : actions/setup-python@v2
109- with :
110- python-version : ' 3.8'
111-
112- - name : Install setup requirements
113- run : |
114- python -m pip install --upgrade setuptools wheel twine
115-
116- - name : Build and package
117- run : |
118- python setup.py sdist bdist_wheel
119- twine check dist/*
120-
121- - name : Publish package
122- if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
123- uses : pypa/gh-action-pypi-publish@release/v1
124- with :
125- user : __token__
126- password : ${{ secrets.PYPI_API_TOKEN }}
127-
128- coveralls_finish :
129- needs : test
130- runs-on : ubuntu-latest
131- steps :
132- - name : Coveralls Finished
133- uses : AndreMiras/coveralls-python-action@develop
134- with :
135- parallel-finished : true
0 commit comments