Skip to content

Commit

Permalink
[QOLDEV-1020] simplify GitHub Actions workflow
Browse files Browse the repository at this point in the history
- Use vanilla CKAN container instead of Docker Compose + Ahoy
  • Loading branch information
ThrawnCA committed Nov 25, 2024
1 parent d65e8b5 commit f31cc35
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
57 changes: 39 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,51 +34,72 @@ jobs:

name: Test on CKAN ${{ matrix.ckan-version }}
runs-on: ubuntu-latest
container: drevops/ci-runner:23.12.0
container:
image: ckan/ckan-dev:${{ matrix.ckan-version }}
options: --user root
services:
solr:
image: ckan/ckan-solr:${{ matrix.ckan-version }}-solr9
postgres:
image: ckan/ckan-postgres-dev:${{ matrix.ckan-version }}
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
redis:
image: redis:3
env:
CKAN_VERSION: ${{ matrix.ckan-version }}
CKAN_SQLALCHEMY_URL: postgresql://ckan_default:pass@postgres/ckan_test
CKAN_DATASTORE_WRITE_URL: postgresql://datastore_write:pass@postgres/datastore_test
CKAN_DATASTORE_READ_URL: postgresql://datastore_read:pass@postgres/datastore_test
CKAN_SOLR_URL: http://solr:8983/solr/ckan
CKAN_REDIS_URL: redis://redis:6379/1

steps:
# Patch https://github.com/actions/runner/issues/863
- name: Preserve $HOME set in the container
run: echo HOME=/root >> "$GITHUB_ENV"

- uses: actions/checkout@v4
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 2

- name: Build
- name: Install requirements
continue-on-error: ${{ matrix.experimental }}
run: bin/build.sh
run: bin/init-ext.sh
timeout-minutes: 15

- name: Unit test
continue-on-error: ${{ matrix.experimental }}
run: bin/test.sh
run: |
cp .docker/test.ini $CKAN_INI
pytest --ckan-ini=$CKAN_INI --cov=ckanext --junit-xml=test/junit/results.xml
timeout-minutes: 10

- name: Create sample data
continue-on-error: ${{ matrix.experimental }}
run: bin/create-test-data.sh

- name: Scenario test
continue-on-error: ${{ matrix.experimental }}
run: bin/test-bdd.sh
run: |
mailmock -p 8025 -o test/emails &
sleep 5
behave --junit -k test/features --tags=smoke --junit-directory=test/junit/ && \
behave --junit -k test/features --tags=-smoke --junit-directory=test/junit/
timeout-minutes: 30

- name: Retrieve logs
if: always()
run: ahoy logs
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 1

- name: Retrieve results
if: always()
run: bin/process-artifacts.sh
uses: jwalton/gh-docker-logs@v2
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 1

- name: Test Summary
uses: test-summary/action@v2
continue-on-error: ${{ matrix.experimental }}
with:
paths: "/tmp/artifacts/junit/*.xml"
paths: "test/junit/*.xml"
if: always()

- name: Upload screenshots
Expand All @@ -87,5 +108,5 @@ jobs:
continue-on-error: ${{ matrix.experimental }}
with:
name: CKAN ${{ matrix.ckan-version }} screenshots
path: /tmp/artifacts/behave/screenshots
path: test/screenshots
timeout-minutes: 1
6 changes: 3 additions & 3 deletions bin/create-test-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CKAN_USER_NAME="${CKAN_USER_NAME:-admin}"
CKAN_DISPLAY_NAME="${CKAN_DISPLAY_NAME:-Administrator}"
CKAN_USER_EMAIL="${CKAN_USER_EMAIL:-admin@localhost}"

. "${APP_DIR}"/bin/activate
. `dirname $0`/activate

add_user_if_needed () {
echo "Adding user '$2' ($1) with email address [$3]"
Expand Down Expand Up @@ -52,7 +52,7 @@ TEST_ORG=$( \
"description": "Organisation for testing issues"}' organization_create
)

TEST_ORG_ID=$(echo $TEST_ORG | $PYTHON "${APP_DIR}"/bin/extract-id.py)
TEST_ORG_ID=$(echo $TEST_ORG | $PYTHON `dirname $0`/extract-id.py)

echo "Assigning test users to '${TEST_ORG_TITLE}' organisation (${TEST_ORG_ID}):"

Expand All @@ -66,4 +66,4 @@ api_call '{"id": "'"${TEST_ORG_ID}"'", "object": "test_org_member", "object_type
# END.
#

. "${APP_DIR}"/bin/deactivate
. `dirname $0`/deactivate
6 changes: 3 additions & 3 deletions bin/init-ext.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ install_requirements () {
done
}

. "${APP_DIR}"/bin/activate
. `dirname $0`/activate
if [ "$CKAN_VERSION" = "2.9" ]; then
pip install "setuptools>=44.1.0,<71"
fi
Expand All @@ -46,5 +46,5 @@ installed_name=$(grep '^\s*name=' setup.py |sed "s|[^']*'\([-a-zA-Z0-9]*\)'.*|\1
# Validate that the extension was installed correctly.
if ! pip list | grep "$installed_name" > /dev/null; then echo "Unable to find the extension in the list"; exit 1; fi

. "${APP_DIR}"/bin/process-config.sh
. "${APP_DIR}"/bin/deactivate
. `dirname $0`/process-config.sh
. `dirname $0`/deactivate

0 comments on commit f31cc35

Please sign in to comment.