build #2361
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
on: | |
push: | |
branches: [ main, release-13.0.x, release-12.0.x, release-11.6.x, release-11.5.x, task/*_compatibility ] | |
tags: | |
- "**" | |
pull_request: | |
branches: [ main, release-13.0.x, release-12.0.x, release-11.6.x, release-11.5.x, task/*_compatibility ] | |
# Run tests daily at 19:23 to get TYPO3 changes and fix them immediately. | |
# @todo: | |
# * run only on dev-<TYPO3-LTS-branch/alias> | |
# * create issue on GH or message via TYPO3 Slack bot, if tests failed | |
schedule: | |
- cron: '23 19 * * *' | |
env: | |
IS_ON_GITHUB_ACTIONS: 'true' | |
CI_BUILD_DIRECTORY: '/home/runner/work/ext-solr/ext-solr/.Build' | |
LOCAL_IMAGE_NAME: 'solrci-image:latest' | |
LOCAL_CONTAINER_NAME: 'solrci-container' | |
TESTING_SOLR_PORT: 8983 | |
LOCAL_VOLUME_NAME: 'solrci-volume' | |
LOCAL_VOLUME_PATH: '/home/runner/work/ext-solr/ext-solr/.Build/data-solr' | |
BRANCH_NAME: 'main' | |
jobs: | |
ci_bootstrapping: | |
name: "Build and test docker image + Collect build matrix" | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.collect_build_matrix.outputs.matrix }} | |
steps: | |
# Workaround for issue with actions/checkout "wrong PR commit checkout": | |
# See: | |
# ** https://github.com/actions/checkout/issues/299#issuecomment-677674415 | |
# ** https://github.com/actions/checkout/issues/1359#issuecomment-1631503791 | |
- | |
name: Checkout current state of Pull Request | |
if: github.event_name == 'pull_request' | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- | |
name: Checkout current state of Branch | |
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} | |
uses: actions/checkout@v4 | |
# End: Workaround for issue with actions/checkout... | |
- | |
name: Collect build matrix | |
id: collect_build_matrix | |
run: | | |
export matrix=$(cat .github/workflows/ci-matrix.json | jq --raw-output .\"${{ env.BRANCH_NAME }}\") | |
echo "Base ref is $GITHUB_BASE_REF" | |
echo "BRANCH_NAME="$BRANCH_NAME | |
echo -e "matrix : " | |
echo $matrix | |
echo "matrix=$(echo $matrix)" >> $GITHUB_OUTPUT | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Build Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Docker/SolrServer/Dockerfile | |
tags: solrci-image:latest | |
outputs: type=docker,dest=/tmp/solrci-image.tar | |
- | |
name: Test Image | |
run: | | |
pwd | |
ls -la ../ | |
docker load --input /tmp/solrci-image.tar | |
docker image ls -a | |
./Build/Test/cibuild_docker.sh | |
- | |
name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: solrci-image | |
path: /tmp/solrci-image.tar | |
retention-days: 1 | |
tests: | |
runs-on: ubuntu-latest | |
needs: ci_bootstrapping | |
continue-on-error: ${{ contains(matrix.TYPO3, '-dev') }} | |
strategy: | |
matrix: ${{ fromJson(needs.ci_bootstrapping.outputs.matrix) }} | |
env: | |
TYPO3_DATABASE_NAME: 'typo3_ci' | |
TYPO3_DATABASE_HOST: '127.0.0.1' | |
TYPO3_DATABASE_USERNAME: 'root' | |
TYPO3_DATABASE_PASSWORD: 'root' | |
TYPO3_VERSION: ${{ matrix.TYPO3 }} | |
name: TYPO3 ${{ matrix.TYPO3 }} on PHP ${{ matrix.PHP }} | |
steps: | |
# Workaround for issue with actions/checkout "wrong PR commit checkout". See: ci_bootstrapping job | |
- | |
name: Checkout current state of Pull Request | |
if: github.event_name == 'pull_request' | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
ref: ${{ github.event.pull_request.head.sha }} | |
- | |
name: Checkout current state of Branch | |
if: ${{ github.event_name == 'push' || github.event_name == 'schedule' }} | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
# End: Workaround for issue with actions/checkout... | |
- | |
name: Mount RAMFS | |
run: | | |
mkdir -p ${{ env.CI_BUILD_DIRECTORY }} | |
sudo mount -t tmpfs -o size=1G none ${{ env.CI_BUILD_DIRECTORY }} | |
sudo mkdir -p ${{ env.CI_BUILD_DIRECTORY }}/data-{solr,mysql} \ | |
&& sudo chown $USER ${{ env.CI_BUILD_DIRECTORY }}/data-mysql \ | |
&& sudo chown 8983:8983 ${{ env.CI_BUILD_DIRECTORY }}/data-solr | |
- | |
name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- | |
name: Download solrci-image from "ci_bootstrapping" job | |
uses: actions/download-artifact@v4 | |
with: | |
name: solrci-image | |
path: /tmp | |
- | |
name: 'Start Docker: Solr, MySQL' | |
run: | | |
docker load --input /tmp/solrci-image.tar | |
docker run --name "MySQL-CI" -v ${{ env.CI_BUILD_DIRECTORY }}/data-mysql:/var/lib/mysql -p 3306:3306 \ | |
-e MYSQL_DATABASE=$TYPO3_DATABASE_NAME \ | |
-e MYSQL_ROOT_PASSWORD=$TYPO3_DATABASE_PASSWORD \ | |
-d mysql:8.0 mysqld --default-authentication-plugin=mysql_native_password | |
sudo chmod g+w "$LOCAL_VOLUME_PATH" | |
docker volume create --name "$LOCAL_VOLUME_NAME" --opt type=none --opt device="$LOCAL_VOLUME_PATH" --opt o=bind | |
docker run --rm --name="$LOCAL_CONTAINER_NAME" -d -p 127.0.0.1:8983:8983 -v "$LOCAL_VOLUME_NAME":"/var/solr" "$LOCAL_IMAGE_NAME" | |
docker ps | |
rm /tmp/solrci-image.tar | |
- | |
name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.PHP }} | |
coverage: pcov | |
tools: composer:2.5.5 | |
- | |
name: CI-Bootstrap | |
run: | | |
./Build/Test/bootstrap.sh --skip-solr-install | |
echo "Current Size of EXT:Solr build Artefacts before run: " \ | |
&& sudo du -sh "${{ env.CI_BUILD_DIRECTORY }}" | |
- | |
name: CI-Build | |
run: | | |
./Build/Test/cibuild.sh | |
echo "Current Size of EXT:Solr build Artefacts after run: " \ | |
&& sudo du -sh "${{ env.CI_BUILD_DIRECTORY }}" \ | |
&& sudo du -sh ${{ env.CI_BUILD_DIRECTORY }}/* | |
- | |
name: Clean up | |
run: | | |
docker stop "MySQL-CI" 2>&1 | |
docker stop "$LOCAL_CONTAINER_NAME" 2>&1 | |
sudo rm -Rf ${{ env.CI_BUILD_DIRECTORY }}/Web/typo3temp/* \ | |
${{ env.CI_BUILD_DIRECTORY }}/data-mysql \ | |
${{ env.CI_BUILD_DIRECTORY }}/data-solr | |
publish: | |
name: Publish new version to TER | |
needs: tests | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-20.04 | |
env: | |
TYPO3_API_TOKEN: ${{ secrets.TYPO3_API_TOKEN }} | |
steps: | |
- | |
name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- | |
name: Check tag | |
run: | | |
TAGGED_VERSION=$(echo "${{ github.ref }}" | awk '{print tolower($0)}') | |
if ! [[ "${TAGGED_VERSION}" =~ ^refs/tags/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}((-pre)?-(alpha|beta|rc)(-?[0-9]{1,3})?)?$ ]]; then | |
>&2 echo -e "Non-stable releases can not be published to TER. The tag ${TAGGED_VERSION} is invalid for TER." | |
exit 0 | |
fi | |
- | |
name: Resolve PHP version to use | |
run: | | |
export PHP_VERSION_TO_USE=$(cat Resources/Private/Php/ComposerLibraries/composer.json | jq --raw-output '.config.platform.php') | |
echo "PHP_VERSION_TO_USE=$PHP_VERSION_TO_USE" >> $GITHUB_ENV | |
- | |
name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ env.PHP_VERSION_TO_USE }} | |
extensions: intl, mbstring, json, zip, curl | |
tools: composer:v2 | |
- | |
name: Install tailor | |
run: composer global require typo3/tailor --prefer-dist --no-progress | |
- | |
name: Publish EXT:solr to TER | |
run: | | |
export RELEASE_VERSION=${GITHUB_REF/refs\/tags\//} | |
export TER_COMMENT=$(git tag -n99 -l "$RELEASE_VERSION" | sed "s/^[0-9.]*[ ]*//g") | |
if [[ -z "${TER_COMMENT// }" ]]; then | |
export TER_COMMENT="Released version $RELEASE_VERSION of EXT:solr" | |
fi | |
echo "Following message will be printed in TER as release description:" | |
echo -e "$TER_COMMENT" | |
if ! composer extension-build; then | |
>&2 echo -e "Something went wrong on bulding EXT:solr for NON-Composer mode. Please look in the job." | |
exit 13 | |
fi | |
php ~/.composer/vendor/bin/tailor ter:publish --comment "$TER_COMMENT" "$RELEASE_VERSION" |