From c32ac19d4ac2069f3dce97fe0cb56c60228faf1c Mon Sep 17 00:00:00 2001 From: ThrawnCA Date: Mon, 25 Nov 2024 14:17:43 +1000 Subject: [PATCH] [QOLDEV-1020] simplify GitHub Actions workflow - Use vanilla CKAN container instead of Docker Compose + Ahoy --- .github/workflows/test.yml | 56 ++++++++++++++++++++++++++------------ bin/create-test-data.sh | 6 ++-- bin/init-ext.sh | 6 ++-- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f2b652..9b02a0e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,43 +34,63 @@ 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: | + 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 @@ -78,7 +98,7 @@ jobs: 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 @@ -87,5 +107,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 diff --git a/bin/create-test-data.sh b/bin/create-test-data.sh index 2ebd0c5..16e31ba 100644 --- a/bin/create-test-data.sh +++ b/bin/create-test-data.sh @@ -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]" @@ -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}):" @@ -66,4 +66,4 @@ api_call '{"id": "'"${TEST_ORG_ID}"'", "object": "test_org_member", "object_type # END. # -. "${APP_DIR}"/bin/deactivate +. `dirname $0`/deactivate diff --git a/bin/init-ext.sh b/bin/init-ext.sh index 350aba5..6e85585 100755 --- a/bin/init-ext.sh +++ b/bin/init-ext.sh @@ -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 @@ -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