diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index d7a39114b..5cde619d9 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -1,9 +1,11 @@ name: Build, Test and Publish on: pull_request: - branches: + branches: - master push: + paths-ignore: + - '.github' branches: - master - stable @@ -11,41 +13,77 @@ on: - cron: '0 2 * * 0' # Weekly on Sundays at 02:00 jobs: - publish: + build: + name: Build, Test and Publish runs-on: ubuntu-latest steps: - uses: actions/checkout@master - name: Reduce Git repository size. run: | git gc --prune=now --aggressive - - name: Publish to Docker Hub - uses: elgohr/Publish-Docker-Github-Action@master - if: github.event_name == 'push' + + - 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 + rm -rf resources/locale/*.UTF-8 + rm -rf resources/locale/translations.json + rm -rf web/static/dist + rm -rf web/static/assets.json + mkdir -p resources/locale/compiled + chmod a+x bin/console + + - name: Pull latest translations. + uses: crowdin/github-action@1.0.6 + with: + upload_translations: false + download_translations: true + export_only_approved: false + push_translations: false + crowdin_branch_name: master + config: crowdin.yaml + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + + - name: Set up test environment. + run: | + 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 + + - 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. + 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 + if: failure() + run: | + cat tests/_output/* + + - name: Publish to Docker Hub + uses: docker/build-push-action@v1 + if: github.event_name == 'push' || github.event_name == 'schedule' with: - name: azuracast/azuracast_web_v2 username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - tag_names: true - cache: ${{ github.event_name != 'schedule' }} - test: - needs: [publish] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - with: - fetch-depth: 1 - - name: Set up test environment - run: | - cp azuracast.sample.env azuracast.env - cp docker-compose.sample.yml docker-compose.yml - cp docker-compose.testing.yml docker-compose.override.yml - chmod 777 tests/_output/ - docker-compose build web - docker-compose run --user="azuracast" --rm web azuracast_install - - name: Run test suite - run: | - docker-compose run --user="azuracast" --rm web composer test - - name: Echo test output directory - if: failure() - run: | - cat tests/_output/* + repository: azuracast/azuracast_web_v2 + cache_froms: azuracast/azuracast_web_v2:latest + tag_with_ref: true + push: true diff --git a/composer.json b/composer.json index c93f17bf4..5eacb03f9 100644 --- a/composer.json +++ b/composer.json @@ -104,12 +104,6 @@ "symfony/polyfill-mbstring": "1.99" }, "scripts": { - "test": [ - "@composer install", - "@phplint", - "@phpstan", - "@codeception-no-coverage" - ], "dev-test": [ "@phplint", "@phpstan", @@ -118,7 +112,11 @@ "phplint": "phplint", "phpstan": "phpstan analyze", "codeception": "codecept run --no-interaction --coverage --coverage-xml --fail-fast", - "codeception-no-coverage": "codecept run --no-interaction" + "codeception-no-coverage": "codecept run --no-interaction", + "ci-import-locales": [ + "@composer install", + "bin/console locale:import" + ] }, "authors": [ { diff --git a/crowdin.yaml b/crowdin.yaml index 2450e62a3..0812e43e9 100644 --- a/crowdin.yaml +++ b/crowdin.yaml @@ -1,6 +1,7 @@ base_url: "https://crowdin.com" project_id_env: CROWDIN_PROJECT_ID api_token_env: CROWDIN_PERSONAL_TOKEN +preserve_hierarchy: true files: - source: /resources/locale/default.pot diff --git a/frontend/package.json b/frontend/package.json index a03a84100..8320f1cd0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,7 +4,8 @@ "scripts": { "build": "gulp", "generate-locales": "gettext-extract --attribute v-translate --keywords '$gettext' --output ../resources/locale/frontend.pot $(find ./vue -type f -name '*.vue')", - "import-locales": "gettext-compile --output ../resources/locale/translations.json $(find ../resources/locale/*.UTF-8 -type f -name 'frontend.po')" + "import-locales": "gettext-compile --output ../resources/locale/translations.json $(find ../resources/locale/*.UTF-8 -type f -name 'frontend.po')", + "ci": "npm run import-locales && npm run build" }, "dependencies": { "@fancyapps/fancybox": "^3.5.7", diff --git a/util/docker/testing/Dockerfile b/util/docker/testing/Dockerfile index 5a8b2f695..387c14b90 100644 --- a/util/docker/testing/Dockerfile +++ b/util/docker/testing/Dockerfile @@ -8,3 +8,4 @@ ENV PATH="${PATH}:/var/azuracast/.composer/vendor/bin" ENV LANG="en_US.UTF-8" \ APPLICATION_ENV="testing" +USER root \ No newline at end of file