Download latest translations and run static build during CI/CD. (#2893)

This commit is contained in:
Buster "Silver Eagle" Neece 2020-05-28 20:01:29 -05:00 committed by GitHub
parent a10e1612b0
commit 1a977119fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 38 deletions

View File

@ -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

View File

@ -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": [
{

View File

@ -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

View File

@ -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",

View File

@ -8,3 +8,4 @@ ENV PATH="${PATH}:/var/azuracast/.composer/vendor/bin"
ENV LANG="en_US.UTF-8" \
APPLICATION_ENV="testing"
USER root