Harden self-hosted CI workflow reliability
This commit is contained in:
@@ -16,9 +16,9 @@ jobs:
|
||||
pull-requests: write
|
||||
checks: write
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
|
||||
ref: ${{ github.event.pull_request.head.sha || github.sha }} # Use PR head when available, otherwise the pushed SHA.
|
||||
fetch-depth: 0 # a full history is required for pull request analysis
|
||||
- name: Prepare Qodana cache directories
|
||||
run: |
|
||||
|
||||
+50
-109
@@ -191,134 +191,75 @@ jobs:
|
||||
runs-on: [self-hosted, Linux, X64, default]
|
||||
continue-on-error: true
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis:7
|
||||
ports:
|
||||
- 6379:6379
|
||||
mysql:
|
||||
image: mysql:8
|
||||
env:
|
||||
MYSQL_DATABASE: app_test
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
ports:
|
||||
- 3306:3306
|
||||
options: >-
|
||||
--health-cmd="mysqladmin ping -h 127.0.0.1 -proot"
|
||||
--health-interval=10s
|
||||
--health-timeout=5s
|
||||
--health-retries=10
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.2'
|
||||
extensions: mysqli, curl, openssl, json, redis
|
||||
ini-values: variables_order=EGPCS
|
||||
- name: Materialize compose env files
|
||||
env:
|
||||
COMPOSE_ENV: ${{ secrets.COMPOSE_ENV }}
|
||||
COMPOSE_ENV_STAGING: ${{ secrets.COMPOSE_ENV_STAGING }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${COMPOSE_ENV}" ]; then
|
||||
echo "Required GitHub secret COMPOSE_ENV is not configured." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${COMPOSE_ENV_STAGING}" ]; then
|
||||
echo "Required GitHub secret COMPOSE_ENV_STAGING is not configured." >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s\n' "$COMPOSE_ENV" > .env
|
||||
printf '%s\n' "$COMPOSE_ENV_STAGING" > .env.staging
|
||||
|
||||
- name: Boot integration stack
|
||||
run: docker compose up -d redis mysql-debug php1
|
||||
|
||||
- name: Resolve dependencies
|
||||
working-directory: services/nginx/app
|
||||
run: composer update --no-interaction --prefer-dist
|
||||
run: docker compose exec -T php1 sh -lc "cd /var/www/html && composer update --no-interaction --prefer-dist"
|
||||
|
||||
- name: Run integration tests
|
||||
working-directory: services/nginx/app
|
||||
env:
|
||||
RUN_INTEGRATION_TESTS: '1'
|
||||
USE_ENV: 'true'
|
||||
DEBUG: '0'
|
||||
ENCRYPTION_KEY: test-key
|
||||
CORS: '*'
|
||||
CONFIG_TIMEZONE: Europe/Copenhagen
|
||||
ECONOMIC_API_APP_ACCESS_GRANT: test
|
||||
ECONOMIC_API_APP_ACCESS_GRANT2: test
|
||||
ECONOMIC_API_APP_SECRET_TOKEN: test
|
||||
WORDPRESS_STATIC_TOKEN: ''
|
||||
EMAIL_WASH_CERTIFICATE_TOKEN: ''
|
||||
WORDPRESS_API_URL: http://localhost
|
||||
MINIO_ENDPOINT: ''
|
||||
MINIO_ACCESS_KEY: ''
|
||||
MINIO_SECRET_KEY: ''
|
||||
SLACK_DEFAULT_WEBHOOK: ''
|
||||
REDIS_CONFIG_HOST: 127.0.0.1
|
||||
REDIS_CONFIG_DATABASE: '0'
|
||||
REDIS_CONFIG_PASSWORD: ''
|
||||
REDIS_CONFIG_PORT: '6379'
|
||||
CONFIG_DB_HOST: 127.0.0.1
|
||||
CONFIG_DB_USER: root
|
||||
CONFIG_DB_PASSWORD: root
|
||||
CONFIG_DB_DATABASE: app_test
|
||||
CONFIG_DB_PORT: '3306'
|
||||
run: composer test:integration
|
||||
run: docker compose exec -T -e RUN_INTEGRATION_TESTS=1 php1 sh -lc "cd /var/www/html && composer test:integration"
|
||||
|
||||
- name: Tear down integration stack
|
||||
if: always()
|
||||
run: docker compose down -v
|
||||
|
||||
api:
|
||||
name: API (advisory)
|
||||
runs-on: [self-hosted, Linux, X64, default]
|
||||
continue-on-error: true
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis:7
|
||||
ports:
|
||||
- 6379:6379
|
||||
mysql:
|
||||
image: mysql:8
|
||||
env:
|
||||
MYSQL_DATABASE: app_test
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
ports:
|
||||
- 3306:3306
|
||||
options: >-
|
||||
--health-cmd="mysqladmin ping -h 127.0.0.1 -proot"
|
||||
--health-interval=10s
|
||||
--health-timeout=5s
|
||||
--health-retries=10
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.2'
|
||||
extensions: mysqli, curl, openssl, json, redis
|
||||
ini-values: variables_order=EGPCS
|
||||
- name: Materialize compose env files
|
||||
env:
|
||||
COMPOSE_ENV: ${{ secrets.COMPOSE_ENV }}
|
||||
COMPOSE_ENV_STAGING: ${{ secrets.COMPOSE_ENV_STAGING }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${COMPOSE_ENV}" ]; then
|
||||
echo "Required GitHub secret COMPOSE_ENV is not configured." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${COMPOSE_ENV_STAGING}" ]; then
|
||||
echo "Required GitHub secret COMPOSE_ENV_STAGING is not configured." >&2
|
||||
exit 1
|
||||
fi
|
||||
printf '%s\n' "$COMPOSE_ENV" > .env
|
||||
printf '%s\n' "$COMPOSE_ENV_STAGING" > .env.staging
|
||||
|
||||
- name: Boot API stack
|
||||
run: docker compose up -d redis mysql-debug php1
|
||||
|
||||
- name: Resolve dependencies
|
||||
working-directory: services/nginx/app
|
||||
run: composer update --no-interaction --prefer-dist
|
||||
run: docker compose exec -T php1 sh -lc "cd /var/www/html && composer update --no-interaction --prefer-dist"
|
||||
|
||||
- name: Run API tests
|
||||
working-directory: services/nginx/app
|
||||
env:
|
||||
RUN_API_TESTS: '1'
|
||||
API_TEST_BOOTSTRAP_SCHEMA: '1'
|
||||
USE_ENV: 'true'
|
||||
DEBUG: '0'
|
||||
ENCRYPTION_KEY: test-key
|
||||
CORS: '*'
|
||||
CONFIG_TIMEZONE: Europe/Copenhagen
|
||||
ECONOMIC_API_APP_ACCESS_GRANT: test
|
||||
ECONOMIC_API_APP_ACCESS_GRANT2: test
|
||||
ECONOMIC_API_APP_SECRET_TOKEN: test
|
||||
WORDPRESS_STATIC_TOKEN: ''
|
||||
EMAIL_WASH_CERTIFICATE_TOKEN: ''
|
||||
WORDPRESS_API_URL: http://localhost
|
||||
MINIO_ENDPOINT: ''
|
||||
MINIO_ACCESS_KEY: ''
|
||||
MINIO_SECRET_KEY: ''
|
||||
SLACK_DEFAULT_WEBHOOK: ''
|
||||
REDIS_CONFIG_HOST: 127.0.0.1
|
||||
REDIS_CONFIG_DATABASE: '0'
|
||||
REDIS_CONFIG_PASSWORD: ''
|
||||
REDIS_CONFIG_PORT: '6379'
|
||||
CONFIG_DB_HOST: 127.0.0.1
|
||||
CONFIG_DB_USER: root
|
||||
CONFIG_DB_PASSWORD: root
|
||||
CONFIG_DB_DATABASE: app_test
|
||||
CONFIG_DB_PORT: '3306'
|
||||
run: composer test:api
|
||||
run: docker compose exec -T -e RUN_API_TESTS=1 -e API_TEST_BOOTSTRAP_SCHEMA=1 php1 sh -lc "cd /var/www/html && composer test:api"
|
||||
|
||||
- name: Tear down API stack
|
||||
if: always()
|
||||
run: docker compose down -v
|
||||
|
||||
Reference in New Issue
Block a user