From f44261b29ba704c67086d2f172ea7c63bac3192a Mon Sep 17 00:00:00 2001 From: "Buster \"Silver Eagle\" Neece" Date: Fri, 29 May 2020 20:36:49 -0500 Subject: [PATCH] Optimize CI testing and web dependencies (#2899) --- .dockerignore | 1 - .github/actions/build/Dockerfile | 10 +++++++ .github/actions/build/action.yml | 5 ++++ .github/actions/build/entrypoint.sh | 19 ++++++++++++ .github/workflows/default.yml | 45 +++++++---------------------- .gitignore | 4 ++- Dockerfile | 2 +- docker-compose.sample.yml | 2 -- vendor/.gitkeep | 1 + 9 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 .github/actions/build/Dockerfile create mode 100644 .github/actions/build/action.yml create mode 100644 .github/actions/build/entrypoint.sh create mode 100644 vendor/.gitkeep diff --git a/.dockerignore b/.dockerignore index f4e94a82f..13da2c8ab 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,7 +8,6 @@ !resources/locale/compiled !util/docker/web !util/openapi.php -!vendor !web !templates !plugins diff --git a/.github/actions/build/Dockerfile b/.github/actions/build/Dockerfile new file mode 100644 index 000000000..781b4c3ac --- /dev/null +++ b/.github/actions/build/Dockerfile @@ -0,0 +1,10 @@ +FROM azuracast/azuracast_testing:latest + +USER root + +COPY ./entrypoint.sh /entrypoint.sh + +RUN chmod a+x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["/bin/true"] \ No newline at end of file diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 000000000..155315bdb --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,5 @@ +name: AzuraCast Build and Test +description: Import translated locales, build static assets and run unit tests. +runs: + using: 'docker' + image: 'Dockerfile' \ No newline at end of file diff --git a/.github/actions/build/entrypoint.sh b/.github/actions/build/entrypoint.sh new file mode 100644 index 000000000..19ab1e4a3 --- /dev/null +++ b/.github/actions/build/entrypoint.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env sh + +# Install Composer dependencies +composer install --no-interaction + +# Import locales on backend +php bin/console locale:import + +# Install NPM dependencies +cd frontend +npm ci + +# Import locales on frontend +npm run import-locales + +# Build frontend assets +npm run build + +eval "$@" diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 3bbf64c8e..9cca2c3b1 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -7,6 +7,7 @@ on: paths-ignore: - '.github' branches: + - ci-testing - master - stable schedule: @@ -22,35 +23,12 @@ jobs: run: | git gc --prune=now --aggressive - - name: Get Composer Cache Directory - id: composer-cache - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache Composer Downloads - uses: actions/cache@v1 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: | - ${{ runner.os }}-composer- - - name: Cache PHP dependencies uses: actions/cache@v1 with: path: vendor key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} - - name: Install Composer Dependencies - uses: php-actions/composer@master - with: - command: install - - - name: Build base Docker image. - run: | - docker pull azuracast/azuracast_web_v2:latest - docker build --cache-from azuracast/azuracast_web_v2:latest -t azuracast/azuracast_web_v2:latest . - - name: Clear existing assets and set permissions. run: | rm -rf resources/locale/compiled @@ -75,25 +53,24 @@ jobs: CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} - - name: Set up test environment. + - name: Import locales, build static assets. + uses: ./.github/actions/build + + - name: Set up functional test environment. run: | + docker pull azuracast/azuracast_web_v2:latest + docker build --cache-from azuracast/azuracast_web_v2:latest -t azuracast/azuracast_web_v2:latest . + cp azuracast.sample.env azuracast.env cp docker-compose.sample.yml docker-compose.yml cp docker-compose.testing.yml docker-compose.override.yml + docker-compose build web + docker-compose run --rm --user="azuracast" web azuracast_install - - name: Import translations into backend. - run: | - docker-compose run --rm web composer ci-import-locales - - - name: Import translations into frontend. - run: | - docker-compose -f frontend/docker-compose.yml run --rm --user=root frontend npm run ci - - - name: Run test suite. + - name: Run functional test suite. run: | chmod 777 tests/_output/ - docker-compose run --rm --user="azuracast" web azuracast_install docker-compose run --rm --user="azuracast" web composer dev-test - name: Echo test output directory diff --git a/.gitignore b/.gitignore index 64805f5de..529769c6d 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,9 @@ tmp/cache/*---* /util/package_usage_report* # Composer-generated content -/vendor/ +/vendor/* +/vendor/**/* +!/vendor/.gitkeep # Ansible deployment files /ansible/ diff --git a/Dockerfile b/Dockerfile index 4cf835048..d671d54c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,7 @@ COPY --chown=azuracast:azuracast . . RUN composer dump-autoload --optimize --classmap-authoritative \ && touch /var/azuracast/.docker -VOLUME ["/var/azuracast/www", "/var/azuracast/backups", "/etc/letsencrypt", "/var/azuracast/sftpgo/persist"] +VOLUME ["/var/azuracast/www_tmp", "/var/azuracast/backups", "/etc/letsencrypt", "/var/azuracast/sftpgo/persist"] # # END Operations as `azuracast` user diff --git a/docker-compose.sample.yml b/docker-compose.sample.yml index bb22355fc..b957dabb4 100644 --- a/docker-compose.sample.yml +++ b/docker-compose.sample.yml @@ -61,7 +61,6 @@ services: LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL} volumes: - letsencrypt:/etc/letsencrypt - - www_data:/var/azuracast/www - tmp_data:/var/azuracast/www_tmp - station_data:/var/azuracast/stations - shoutcast2_install:/var/azuracast/servers/shoutcast2 @@ -278,6 +277,5 @@ volumes: sftpgo_data: {} station_data: {} tmp_data: {} - www_data: {} redis_data: {} backups: {} \ No newline at end of file diff --git a/vendor/.gitkeep b/vendor/.gitkeep new file mode 100644 index 000000000..c693f138c --- /dev/null +++ b/vendor/.gitkeep @@ -0,0 +1 @@ +keep \ No newline at end of file