From 020365154464ea30bd5378ddc880415832d61c6d Mon Sep 17 00:00:00 2001 From: billy clark Date: Thu, 2 Dec 2021 13:50:16 -0500 Subject: [PATCH 01/10] Utilize GHA for unit tests (#1258) --- .github/workflows/unit-tests.yml | 22 ++++++++++++++++++++++ README.md | 19 +++++-------------- 2 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/unit-tests.yml diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml new file mode 100644 index 0000000000..f756255a6a --- /dev/null +++ b/.github/workflows/unit-tests.yml @@ -0,0 +1,22 @@ +name: Run unit tests + +# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on +on: + pull_request: + + push: + branches: + - develop + - staging + +jobs: + unit-tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run unit tests + working-directory: ./docker/ + run: make unit-tests + diff --git a/README.md b/README.md index 1d76e8587d..1cde0e7c30 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,7 @@ To report an issue using the **Language Forge** service, email "languageforgeiss ## Special Thanks To ## - ![BrowserStack Logo](readme_images/browserstack-logo.png "BrowserStack") for mobile device testing. -- -[![Bugsnag logo](readme_images/bugsnag-logo.png "Bugsnag")](https://bugsnag.com/blog/bugsnag-loves-open-source) for error reporting. +- [![Bugsnag logo](readme_images/bugsnag-logo.png "Bugsnag")](https://bugsnag.com/blog/bugsnag-loves-open-source) for error reporting. ## Developers ## @@ -23,14 +22,6 @@ We use [Gitflow](http://nvie.com/posts/a-successful-git-branching-model/) mostly | ------------- | --------- | ----------- | | `master` | `staging` | `prod` | -### CI Builds ### - -Status of builds from our continuous integration (CI) [server](https://build.palaso.org): - -| PHP Unit Tests | E2E Tests | -| ----------- | ---------- | -| [![Build Status](https://build.palaso.org/app/rest/builds/buildType:LanguageForgeDocker_PhpTests/statusIcon.svg)](https://build.palaso.org/buildConfiguration/LanguageForgeDocker_PhpTests) | [![Build Status](https://build.palaso.org/app/rest/builds/buildType:LanguageForgeDocker_E2eTests/statusIcon.svg)](https://build.palaso.org/buildConfiguration/LanguageForgeDocker_E2eTests) | - ### Deployed Sites ### | Staging | Production | @@ -85,13 +76,13 @@ Other useful resources: > Sometimes there may be a need to hit the locally running app from a device other than the machine the app is running on. In order to do that, you'll need to do the following: > 1. Figure out your local ip address > 1. Access the app via http at that address -> +> > On a Mac for example: > ``` > ifconfig | grep broadcast > inet 192.168.161.99 netmask 0xfffffc00 broadcast 192.168.163.255 > ``` -> +> > then hit `http://192.168.161.99` from your phone or other device on the same network. > > NOTE: disabling cache on your device may not be trivial, you'll either need to wipe the site settings on your device's browser or you'll need to do it via USB debugging. @@ -188,7 +179,7 @@ To debug the Language Forge application locally, follow these steps: - In VS Code, set a breakpoint on a line of code that should be executed - Click on the `Run and Debug` area of VS Code, then click the green play icon next to `XDebug` in the configuration dropdown. -![XDebug](readme_images/xdebug1.png "Debugging with XDebug")] +![XDebug](readme_images/xdebug1.png "Debugging with XDebug")] - The VSCode status bar will turn orange when XDebug is active - open the application in your web browser (`https://localhost`) and use the application such that you execute the code where you have a breakpoint set @@ -207,7 +198,7 @@ To debug the PHP tests, follow these steps: - In VS Code, set a breakpoint on a line of code in one of the PHP tests (in the `test/php` folder) - Click on the `Run and Debug` area of VS Code, then click the green play icon next to `XDebug` in the configuration dropdown. -![XDebug](readme_images/xdebug1.png "Debugging with XDebug")] +![XDebug](readme_images/xdebug1.png "Debugging with XDebug")] - The VSCode status bar will turn orange when XDebug is active - run `make unit-tests` in the terminal From 0fe2d528ae52b052d71c071481a5fa0a81de7ff6 Mon Sep 17 00:00:00 2001 From: billy clark Date: Sat, 11 Dec 2021 08:43:47 -0500 Subject: [PATCH 02/10] Parameterized docker image tag for ad-hoc publishing (#1265) --- .github/workflows/build-and-publish-adhoc.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-publish-adhoc.yml b/.github/workflows/build-and-publish-adhoc.yml index 2494cb6b26..542b834049 100644 --- a/.github/workflows/build-and-publish-adhoc.yml +++ b/.github/workflows/build-and-publish-adhoc.yml @@ -2,22 +2,25 @@ name: Publish ad-hoc image to Docker Hub # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on on: - push: - paths: - - '**build-and-publish-adhoc.yml' + workflow_dispatch: + inputs: + # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputsinput_id + tag: + description: Docker tag to publish + required: true jobs: build-n-publish: runs-on: ubuntu-latest env: - IMAGE: sillsdev/web-languageforge:pr-1247-blue + IMAGE: sillsdev/web-languageforge steps: - uses: actions/checkout@v2 - name: Build and tag app - run: docker build -t ${{ env.IMAGE }}-${GITHUB_SHA} -f docker/app/Dockerfile . + run: docker build -t ${{ env.IMAGE }}:${{ github.event.inputs.tag }} -f docker/app/Dockerfile . - name: Log in to Docker Hub uses: docker/login-action@v1 @@ -27,4 +30,4 @@ jobs: - name: Publish image run: | - docker push ${{ env.IMAGE }}-${GITHUB_SHA} + docker push ${{ env.IMAGE }}:${{ github.event.inputs.tag }} From 75416f7d2430579ba8cd11ab0e7417870a4f6a88 Mon Sep 17 00:00:00 2001 From: billy clark Date: Mon, 13 Dec 2021 08:20:16 -0500 Subject: [PATCH 03/10] Move to a 2-branch model (#1267) --- .github/workflows/build-and-deploy-images.yml | 34 +++---------------- README.md | 22 ++++++++---- 2 files changed, 19 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build-and-deploy-images.yml b/.github/workflows/build-and-deploy-images.yml index e9052a2add..10c57dad0c 100644 --- a/.github/workflows/build-and-deploy-images.yml +++ b/.github/workflows/build-and-deploy-images.yml @@ -6,36 +6,10 @@ on: tags: - "v*" branches: - - staging - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + - develop # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - environment: - # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources - runs-on: ubuntu-latest - - steps: - - name: What version of Make is installed - run: make --version - - - name: What version of Docker is installed - run: docker --version - - - name: What version of Docker-Compose is installed - run: docker-compose --version - - - name: CPU info - run: cat /proc/cpuinfo - - - name: RAM info - run: free - - - name: Disk info - run: df -h - build-n-publish: runs-on: ubuntu-latest @@ -43,10 +17,10 @@ jobs: - uses: actions/checkout@v2 - name: Set BUILD_VERSION for Staging - if: github.ref == 'refs/heads/staging' + if: github.ref == 'refs/heads/develop' run: |- - echo "BUILD_VERSION=staging-$GITHUB_SHA" >> "$GITHUB_ENV" - echo "BUILD_VERSION_LATEST=staging" >> "$GITHUB_ENV" + echo "BUILD_VERSION=develop-$(date +%Y%m%d)-$GITHUB_SHA" >> "$GITHUB_ENV" + echo "BUILD_VERSION_LATEST=develop" >> "$GITHUB_ENV" - name: Set BUILD_VERSION for Production from git tag if: startsWith(github.ref, 'refs/tags/v') diff --git a/README.md b/README.md index 1cde0e7c30..dad8fbe7fd 100644 --- a/README.md +++ b/README.md @@ -16,16 +16,24 @@ To report an issue using the **Language Forge** service, email "languageforgeiss ## Developers ## -We use [Gitflow](http://nvie.com/posts/a-successful-git-branching-model/) mostly, however we do not utilize a `develop` branch. All work starts and returns to the `master` branch. Deployment of software to a staging and/or a production environment occur through the use of the respective branches being fast-forwarded to the appropriate commit on `master` which will in turn kick off our automated deployment processes. +We use a modified [Gitflow](http://nvie.com/posts/a-successful-git-branching-model/) process to manage changes. -| Master Branch | Staging Branch (for testing) | Production Branch | -| ------------- | --------- | ----------- | -| `master` | `staging` | `prod` | +### Typical ### +1. Create a branch off of `develop` +1. Create a PR back into `develop` +1. Once approved and merged, test those changes on [qa.languageforge.org](https://qa.languageforge.org) +1. Once you are satisifed with the changes, coordinate with the team to deliver those changes to the production environment +1. Team leads will determine when the right time to cut a release, i.e., tag and deploy, typically this should be within a day or two + +### Exception ### +1. There may be times when it's necessary to create a branch off of `master` (e.g. a hotfix for the production environment) +1. Coordinate with the team to deliver those changes to the production environment +1. Team leads will determine when the right time to cut a release, i.e., tag and deploy, this would likely be right away under these exceptional circumstances ### Deployed Sites ### | Staging | Production | -| -- | ---- | +| - | - | | [qa.languageforge.org](https://qa.languageforge.org) | [languageforge.org](https://languageforge.org) | ## Style Guides ## @@ -235,7 +243,7 @@ Language Forge is built to run in a containerized environment. For now, Kuberne Staging deployments can be run with `VERSION= make deploy-staging`. Current workflow: -1. merge commits into or make commits on `staging` branch +1. merge commits into or make commits on `develop` branch 1. this will kick off the GHA (`.github/workflows/build-and-deploy-images.yml`) to build and publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) 1. then the deployment scripts can be run either manually or via the TeamCity deploy job @@ -243,7 +251,7 @@ Current workflow: Production deployments can be run with `VERSION= make deploy-prod`. Current workflow: -1. merge from `staging` into `master` +1. merge from `develop` into `master` 1. "Draft a new release" on https://github.com/sillsdev/web-languageforge/releases with a `v#.#.#` tag format 1. "Publish" the new release 1. this will kick off the GHA (`.github/workflows/build-and-deploy-images.yml`) to build and publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) From c0dcbd0d08baed3b0361d82bc628b89096cd5bd5 Mon Sep 17 00:00:00 2001 From: billy clark Date: Tue, 14 Dec 2021 12:35:17 -0500 Subject: [PATCH 04/10] Refactored actions to include the staging environment deployment (#1268) --- .github/workflows/build-and-deploy-images.yml | 9 --- .github/workflows/deployment-staging.yml | 64 +++++++++++++++++++ README.md | 5 +- docker/Makefile | 7 -- docker/docker-compose.yml | 1 + 5 files changed, 67 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/deployment-staging.yml diff --git a/.github/workflows/build-and-deploy-images.yml b/.github/workflows/build-and-deploy-images.yml index 10c57dad0c..1ae46ca1b3 100644 --- a/.github/workflows/build-and-deploy-images.yml +++ b/.github/workflows/build-and-deploy-images.yml @@ -5,8 +5,6 @@ on: push: tags: - "v*" - branches: - - develop # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -16,14 +14,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set BUILD_VERSION for Staging - if: github.ref == 'refs/heads/develop' - run: |- - echo "BUILD_VERSION=develop-$(date +%Y%m%d)-$GITHUB_SHA" >> "$GITHUB_ENV" - echo "BUILD_VERSION_LATEST=develop" >> "$GITHUB_ENV" - - name: Set BUILD_VERSION for Production from git tag - if: startsWith(github.ref, 'refs/tags/v') # define BUILD_VERSION as stripping off initial 11 characters, i.e. "refs/tags/v" run: |- echo "BUILD_VERSION=$(echo ${GITHUB_REF:11})" >> "$GITHUB_ENV" diff --git a/.github/workflows/deployment-staging.yml b/.github/workflows/deployment-staging.yml new file mode 100644 index 0000000000..cc8a4ded5d --- /dev/null +++ b/.github/workflows/deployment-staging.yml @@ -0,0 +1,64 @@ +name: Deploy to staging + +# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on +on: + push: + branches: + - develop + +jobs: + build: + runs-on: ubuntu-latest + + outputs: + IMAGE: ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG }} + + steps: + - + uses: actions/checkout@v2 + - + name: Build app + working-directory: ./docker/ + run: docker-compose build --build-arg ENVIRONMENT=production app + - + name: Check unit tests + working-directory: ./docker/ + run: make unit-tests + # - + # name: Check e2e tests + # working-directory: ./docker/ + # run: make e2e-tests + - + name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + - + name: Establish image name + id: image + run: | + echo ::set-output name=NAMESPACE::sillsdev/web-languageforge + echo ::set-output name=TAG::develop-$(date +%Y%m%d)-${{ github.sha }} + - + name: Tag images + run: docker tag lf-app ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG }} + - + name: Publish image + run: docker push ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG }} + + deploy: + runs-on: [self-hosted, languageforge] + + needs: build + + steps: + - + name: Install kubectl + run: | + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl + kubectl version + - + name: Deploy to staging + run: kubectl --context ${{ secrets.LTOPS_K8S_STAGING_CONTEXT }} set image deployment/app app=${{ needs.build.outputs.IMAGE }} diff --git a/README.md b/README.md index dad8fbe7fd..c94cd5f113 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,7 @@ After a minute or two, your source or test changes should be applied and you sho ### Building for deployment -1. Refer to `/.github/workflows/build-and-deploy-images.yml` for build commands. +1. Refer to `/.github/workflows/build-and-deploy-images.yml` for production build commands and `/.github/workflows/deployment-staging.yml` for staging build commands. ### Visual Studio Code ### @@ -244,8 +244,7 @@ Staging deployments can be run with `VERSION= make de Current workflow: 1. merge commits into or make commits on `develop` branch -1. this will kick off the GHA (`.github/workflows/build-and-deploy-images.yml`) to build and publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) -1. then the deployment scripts can be run either manually or via the TeamCity deploy job +1. this will kick off the GHA (`.github/workflows/deployment-staging.yml`) to build, publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) and deploy to the staging environment. ### Production ### Production deployments can be run with `VERSION= make deploy-prod`. diff --git a/docker/Makefile b/docker/Makefile index e5b9a7e978..83cb00f714 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -24,14 +24,7 @@ endif .PHONY: unit-tests unit-tests: build docker-compose build test-php -ifeq ("$(TEAMCITY_VERSION)",$()) - # developer machine docker-compose run test-php -else - # teamcity CI - docker-compose run -e WEBSITE=languageforge.org --name unittests test-php - docker cp unittests:/var/www/PhpUnitTests.xml .. -endif .PHONY: build build: diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 8b8534f4fa..1c01fed532 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -223,6 +223,7 @@ services: environment: - WAIT_HOSTS=db:27017, mail:25 - ENVIRONMENT=development + - WEBSITE=localhost.languageforge.org - DATABASE=scriptureforge_test - MONGODB_CONN=mongodb://db:27017 - MAIL_HOST=mail From bffa3804fde0e1a729dba1b0a334b7443310cadf Mon Sep 17 00:00:00 2001 From: billy clark Date: Wed, 15 Dec 2021 10:06:01 -0500 Subject: [PATCH 05/10] removed dupe job run (#1270) --- .github/workflows/unit-tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f756255a6a..955518fd04 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -6,7 +6,6 @@ on: push: branches: - - develop - staging jobs: From 453a09a5277960b52ad812e453746127162d5d51 Mon Sep 17 00:00:00 2001 From: Christopher Hirt Date: Tue, 11 Jan 2022 15:58:29 +0700 Subject: [PATCH 06/10] normalize search string to NFC before comparison (#1272) Normalize the search string to NFC since all data in LF is normalized to NFC on disk. This allows for exact match or ignore diacritic queries to work regardless of form or language, e.g. Korean. A note about this fix: - All data is normalized to NFC in the database on write. It's been this way for years. - @longrunningprocess 's addition in #1243 normalized the query to NFD for the purposes of removing diacritics from the data and query. This a fine approach. - This PR could have chosen to normalize all data to NFD for comparison under all circumstances given the second point above, however I chose to stick with NFC since that is what the data is underneath. Either way works. Fixes #1244 --- src/angular-app/bellows/core/offline/editor-data.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/angular-app/bellows/core/offline/editor-data.service.ts b/src/angular-app/bellows/core/offline/editor-data.service.ts index 24f37ed487..184f168429 100644 --- a/src/angular-app/bellows/core/offline/editor-data.service.ts +++ b/src/angular-app/bellows/core/offline/editor-data.service.ts @@ -457,13 +457,13 @@ export class EditorDataService { // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escapes // https://unicode.org/reports/tr44/#Diacritic // https://stackoverflow.com/a/37511463/10818013 - - return input.normalize('NFD').replace(/\p{Diacritic}/gu, '') +// Convert to NFD in order to remove any code points with the property 'Diacritic', then convert back to NFC for comparison + return input.normalize('NFD').replace(/\p{Diacritic}/gu, '').normalize('NFC'); } private entryMeetsFilterCriteria(config: any, entry: LexEntry): boolean { if (this.entryListModifiers.filterText() !== '') { - const rawQuery = this.entryListModifiers.filterText() + const rawQuery = this.entryListModifiers.filterText().normalize('NFC'); const normalizedQuery = this.entryListModifiers.matchDiacritic ? rawQuery : this.removeDiacritics(rawQuery); const regexSafeQuery = this.escapeRegex(normalizedQuery); const queryRegex = new RegExp(this.entryListModifiers.wholeWord ? `\\b${regexSafeQuery}\\b` : regexSafeQuery, 'i'); From 69a155d628e0c260cc7d92fde01a0bc445366e4d Mon Sep 17 00:00:00 2001 From: billy clark Date: Mon, 10 Jan 2022 14:42:37 -0500 Subject: [PATCH 07/10] establish base-php published image to speed up CI builds - created a base-php build and publish workflow - moved initial lines from base-app into it's own Dockerfile for separate building/publishing --- .../workflows/build-and-publish-base-php.yml | 29 +++++++++++++++++++ docker/app/Dockerfile | 14 +-------- docker/base-php/Dockerfile | 13 +++++++++ 3 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/build-and-publish-base-php.yml create mode 100644 docker/base-php/Dockerfile diff --git a/.github/workflows/build-and-publish-base-php.yml b/.github/workflows/build-and-publish-base-php.yml new file mode 100644 index 0000000000..38e50234f1 --- /dev/null +++ b/.github/workflows/build-and-publish-base-php.yml @@ -0,0 +1,29 @@ +name: Build and publish a base PHP image for LF + +# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on +on: + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + build-n-publish: + runs-on: ubuntu-latest + + env: + IMAGE: sillsdev/web-languageforge:base-php + + steps: + - uses: actions/checkout@v2 + + - name: Build and tag base image + run: docker build -t ${{ env.IMAGE }} -f docker/base-php/Dockerfile . + + - name: Log in to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }} + + - name: Publish image + run: | + docker push ${{ env.IMAGE }} diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index 6bb38e0933..feee5af868 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -39,19 +39,7 @@ FROM ${ENVIRONMENT}-ui-builder AS ui-builder RUN npm run build:${NPM_BUILD_SUFFIX} # APP-BASE -FROM php:7.3.28-apache AS base-app - -# install apt packages -# p7zip-full - used by LF application for unzipping lexicon uploads -# unzip - used by LF application for unzipping lexicon uploads -# gnupg2 - necessary for LFMerge package installation via SIL sources (will be uninstalled in production) -# curl - used by LF application -RUN apt-get update && apt-get -y install p7zip-full unzip gnupg2 curl && rm -rf /var/lib/apt/lists/* - -# see https://github.com/mlocati/docker-php-extension-installer -# PHP extensions required by the LF application -COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ -RUN install-php-extensions gd mongodb intl +FROM sillsdev/web-languageforge:base-php AS base-app # install and configure LFMerge # LFMerge required apt packages diff --git a/docker/base-php/Dockerfile b/docker/base-php/Dockerfile new file mode 100644 index 0000000000..277db1cb0d --- /dev/null +++ b/docker/base-php/Dockerfile @@ -0,0 +1,13 @@ +FROM php:7.3.28-apache + +# install apt packages +# p7zip-full - used by LF application for unzipping lexicon uploads +# unzip - used by LF application for unzipping lexicon uploads +# gnupg2 - necessary for LFMerge package installation via SIL sources (will be uninstalled in production) +# curl - used by LF application +RUN apt-get update && apt-get -y install p7zip-full unzip gnupg2 curl && rm -rf /var/lib/apt/lists/* + +# see https://github.com/mlocati/docker-php-extension-installer +# PHP extensions required by the LF application +COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ +RUN install-php-extensions gd mongodb intl From d5fcfa2039b015ba8270917fbd4e7499a9da4dc7 Mon Sep 17 00:00:00 2001 From: Chris Hirt Date: Tue, 11 Jan 2022 16:30:54 +0700 Subject: [PATCH 08/10] move remaining lines of base-app into base-php Dockerfile Move the rest of the local base-app into the published base-php image --- docker/app/Dockerfile | 39 +++----------------------------------- docker/base-php/Dockerfile | 30 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/docker/app/Dockerfile b/docker/app/Dockerfile index feee5af868..eab952c17b 100644 --- a/docker/app/Dockerfile +++ b/docker/app/Dockerfile @@ -38,43 +38,10 @@ FROM ${ENVIRONMENT}-ui-builder AS ui-builder # artifacts built to /data/src/dist RUN npm run build:${NPM_BUILD_SUFFIX} -# APP-BASE -FROM sillsdev/web-languageforge:base-php AS base-app - -# install and configure LFMerge -# LFMerge required apt packages -# python - required by Mercurial (written in Python), which is bundled in the LFMerge apt package -# lfmerge - main package, from SIL sources -# rsyslog - lfmerge logs to rsyslog and expects this to exist -# logrotate - TODO: is this required? -# iputils-ping - Chorus (part of LFMerge) requires the "ping" command to be available on the command line -RUN curl -L http://linux.lsdev.sil.org/downloads/sil-testing.gpg | apt-key add - \ -&& echo "deb http://linux.lsdev.sil.org/ubuntu bionic main" > /etc/apt/sources.list.d/linux-lsdev-sil-org.list \ -&& apt-get update \ -&& apt-get install --yes --no-install-recommends python lfmerge rsyslog logrotate iputils-ping \ -&& rm -rf /var/lib/apt/lists/* -COPY docker/app/lfmerge.conf /etc/languageforge/conf/sendreceive.conf -COPY docker/app/lfmergeqm-background.sh / -RUN adduser www-data fieldworks \ -&& chown -R www-data:www-data /var/lib/languageforge \ -&& chmod 0755 /var/lib/languageforge \ -&& mkdir -m 02775 -p /var/www/.local \ -&& chown www-data:www-data /var/www/.local - -# rsyslog customizations (imklog reads kernel messages, which isn't allowed or desired in Docker containers) -RUN sed -i '/load="imklog"/s/^/#/' /etc/rsyslog.conf - -# php customizations -COPY docker/app/customizations.php.ini $PHP_INI_DIR/conf.d/ - -# apache2 customizations -RUN a2enmod headers rewrite -COPY docker/app/000-default.conf /etc/apache2/sites-enabled - # COMPOSER-BUILDER # download composer app dependencies # git - needed for composer install -FROM base-app AS composer-builder +FROM sillsdev/web-languageforge:base-php AS composer-builder WORKDIR /composer COPY src/composer.json src/composer.lock /composer/ ENV COMPOSER_ALLOW_SUPERUSER=1 @@ -82,13 +49,13 @@ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/* \ && install-php-extensions @composer && composer install # PRODUCTION IMAGE -FROM base-app AS production-app +FROM sillsdev/web-languageforge:base-php AS production-app RUN rm /usr/local/bin/install-php-extensions RUN apt-get remove -y gnupg2 RUN mv $PHP_INI_DIR/php.ini-production $PHP_INI_DIR/php.ini # DEVELOPMENT IMAGE -FROM base-app AS development-app +FROM sillsdev/web-languageforge:base-php AS development-app RUN install-php-extensions xdebug COPY docker/app/docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d RUN mv $PHP_INI_DIR/php.ini-development $PHP_INI_DIR/php.ini diff --git a/docker/base-php/Dockerfile b/docker/base-php/Dockerfile index 277db1cb0d..c46ebd0b59 100644 --- a/docker/base-php/Dockerfile +++ b/docker/base-php/Dockerfile @@ -11,3 +11,33 @@ RUN apt-get update && apt-get -y install p7zip-full unzip gnupg2 curl && rm -rf # PHP extensions required by the LF application COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ RUN install-php-extensions gd mongodb intl + +# install and configure LFMerge +# LFMerge required apt packages +# python - required by Mercurial (written in Python), which is bundled in the LFMerge apt package +# lfmerge - main package, from SIL sources +# rsyslog - lfmerge logs to rsyslog and expects this to exist +# logrotate - TODO: is this required? +# iputils-ping - Chorus (part of LFMerge) requires the "ping" command to be available on the command line +RUN curl -L http://linux.lsdev.sil.org/downloads/sil-testing.gpg | apt-key add - \ +&& echo "deb http://linux.lsdev.sil.org/ubuntu bionic main" > /etc/apt/sources.list.d/linux-lsdev-sil-org.list \ +&& apt-get update \ +&& apt-get install --yes --no-install-recommends python lfmerge rsyslog logrotate iputils-ping \ +&& rm -rf /var/lib/apt/lists/* +COPY docker/app/lfmerge.conf /etc/languageforge/conf/sendreceive.conf +COPY docker/app/lfmergeqm-background.sh / +RUN adduser www-data fieldworks \ +&& chown -R www-data:www-data /var/lib/languageforge \ +&& chmod 0755 /var/lib/languageforge \ +&& mkdir -m 02775 -p /var/www/.local \ +&& chown www-data:www-data /var/www/.local + +# rsyslog customizations (imklog reads kernel messages, which isn't allowed or desired in Docker containers) +RUN sed -i '/load="imklog"/s/^/#/' /etc/rsyslog.conf + +# php customizations +COPY docker/app/customizations.php.ini $PHP_INI_DIR/conf.d/ + +# apache2 customizations +RUN a2enmod headers rewrite +COPY docker/app/000-default.conf /etc/apache2/sites-enabled From c51ccf2607a6969a87196f4e9cd1db1e6d4a79ab Mon Sep 17 00:00:00 2001 From: Rick Bartlett Date: Tue, 11 Jan 2022 14:40:25 -0800 Subject: [PATCH 09/10] Feature/entry number for display and navigation (#1215) * initial commit for goto entry * Add entry number to Entry card * Remove unneeded import * clear goto after valid move * Add function to check if filtering and sorting is on. Add implementation ng-disabled to back, forward and goto elements * Added controller model to imnput element to track current enrty index * Change input tool tip message * Remove unused binding to ui element * Min and Max validation properties were inadvertently removed. dc-entry entry-index="$ctrl.entryIndex() removed on rebase, adding back * reset input value on blur; hide control on filter This change adds a ng-blur handler that resets the value of the numeric input to the current entry index. This fixes the input having a sticky invalid state/red box when the user clicks a button or loses focus on the input. Additionally, we hide the controls when the filter is active, instead of disabling. Co-authored-by: Chris Hirt --- .../core/offline/editor-data.service.ts | 11 +++++++++++ .../core/lexicon-editor-data.service.ts | 1 + .../languageforge/lexicon/editor/_editor.scss | 17 +++++++++++++++++ .../lexicon/editor/editor-entry.view.html | 2 +- .../lexicon/editor/editor.component.html | 4 +++- .../lexicon/editor/editor.component.ts | 19 +++++++++++++++++++ .../editor/field/dc-entry.component.ts | 5 +++-- 7 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/angular-app/bellows/core/offline/editor-data.service.ts b/src/angular-app/bellows/core/offline/editor-data.service.ts index 184f168429..c0a5b8db6f 100644 --- a/src/angular-app/bellows/core/offline/editor-data.service.ts +++ b/src/angular-app/bellows/core/offline/editor-data.service.ts @@ -269,6 +269,17 @@ export class EditorDataService { return index; } + // find entry id from index number, used to goto and display editor record + getIdInFilteredList = (index: number): string => { + let list = this.filteredEntries; + let id: string; + if(index > 0 && index <= list.length){ + let entry = list[index-1]; + id = entry.id; + } + return id; + } + sortEntries = (shouldResetVisibleEntriesList: boolean): angular.IPromise => { const startTime = performance.now(); return this.configService.getEditorConfig().then(config => { diff --git a/src/angular-app/languageforge/lexicon/core/lexicon-editor-data.service.ts b/src/angular-app/languageforge/lexicon/core/lexicon-editor-data.service.ts index 2b3fb6a04c..ff8fe154f6 100644 --- a/src/angular-app/languageforge/lexicon/core/lexicon-editor-data.service.ts +++ b/src/angular-app/languageforge/lexicon/core/lexicon-editor-data.service.ts @@ -17,6 +17,7 @@ export class LexiconEditorDataService { removeEntryFromLists = this.editorDataService.removeEntryFromLists; addEntryToEntryList = this.editorDataService.addEntryToEntryList; getIndexInList = this.editorDataService.getIndexInList; + getIdInFilteredList = this.editorDataService.getIdInFilteredList; showInitialEntries = this.editorDataService.showInitialEntries; showMoreEntries = this.editorDataService.showMoreEntries; sortEntries = this.editorDataService.sortEntries; diff --git a/src/angular-app/languageforge/lexicon/editor/_editor.scss b/src/angular-app/languageforge/lexicon/editor/_editor.scss index 961b32cd67..220bed86af 100644 --- a/src/angular-app/languageforge/lexicon/editor/_editor.scss +++ b/src/angular-app/languageforge/lexicon/editor/_editor.scss @@ -827,3 +827,20 @@ dc-entry .card { form.submitted .ng-invalid { border: 1px solid #f00; } + +// remove up/down arrows for goto Entry +.gotoEntry { + width: 60px; + &::-webkit-inner-spin-button{ display: none; } + -moz-appearance:textfield; +} + +.gotoEntry.ng-invalid { + border: 3px solid #f00; +} + +.gotoEntry:focus.ng-invalid { + background-color: #fff; + outline: none; + border: 3px solid #f00; +} diff --git a/src/angular-app/languageforge/lexicon/editor/editor-entry.view.html b/src/angular-app/languageforge/lexicon/editor/editor-entry.view.html index f1b0bb2ad4..341ff42cff 100644 --- a/src/angular-app/languageforge/lexicon/editor/editor-entry.view.html +++ b/src/angular-app/languageforge/lexicon/editor/editor-entry.view.html @@ -116,7 +116,7 @@ - + diff --git a/src/angular-app/languageforge/lexicon/editor/editor.component.html b/src/angular-app/languageforge/lexicon/editor/editor.component.html index fb674e3dd9..dfb35c009b 100644 --- a/src/angular-app/languageforge/lexicon/editor/editor.component.html +++ b/src/angular-app/languageforge/lexicon/editor/editor.component.html @@ -11,10 +11,12 @@ List
-
+
+ diff --git a/src/angular-app/languageforge/lexicon/editor/editor.component.ts b/src/angular-app/languageforge/lexicon/editor/editor.component.ts index 93c2fb966f..655076db62 100644 --- a/src/angular-app/languageforge/lexicon/editor/editor.component.ts +++ b/src/angular-app/languageforge/lexicon/editor/editor.component.ts @@ -49,6 +49,11 @@ export class LexiconEditorController implements angular.IController { lastSavedDate = new Date(); currentEntry: LexEntry = new LexEntry(); + + currentIndex = { + index: -1 + } + commentContext = { contextGuid: '' }; @@ -469,6 +474,20 @@ export class LexiconEditorController implements angular.IController { this.goToEntry(id); } + gotoToEntry(index: number, isValid: boolean) { + if (isValid) { + let id = this.editorService.getIdInFilteredList(Number(index)); + this.editEntryAndScroll(id); + } + } + + entryIndex(): number { + let id = this.currentEntry.id; + let index = this.editorService.getIndexInList(id, this.entries) + this.currentIndex.index = index + 1; + return this.currentIndex.index; + } + canSkipToEntry(distance: number): boolean { const i = this.editorService.getIndexInList(this.currentEntry.id, this.visibleEntries) + distance; return i >= 0 && i < this.visibleEntries.length; diff --git a/src/angular-app/languageforge/lexicon/editor/field/dc-entry.component.ts b/src/angular-app/languageforge/lexicon/editor/field/dc-entry.component.ts index 00f7d6ab25..06ec517228 100644 --- a/src/angular-app/languageforge/lexicon/editor/field/dc-entry.component.ts +++ b/src/angular-app/languageforge/lexicon/editor/field/dc-entry.component.ts @@ -6,11 +6,11 @@ import {LexEntry} from '../../shared/model/lex-entry.model'; import {LexSense} from '../../shared/model/lex-sense.model'; import {LexConfigFieldList} from '../../shared/model/lexicon-config.model'; import {FieldControl} from './field-control.model'; - export class FieldEntryController implements angular.IController { model: LexEntry; config: LexConfigFieldList; control: FieldControl; + entryIndex: number; contextGuid: string = ''; fieldName: string = 'entry'; @@ -83,7 +83,8 @@ export const FieldEntryComponent: angular.IComponentOptions = { bindings: { model: '=', config: '<', - control: '<' + control: '<', + entryIndex: '<' }, controller: FieldEntryController, templateUrl: '/angular-app/languageforge/lexicon/editor/field/dc-entry.component.html' From 8faf84a3c51d757231d060ef329bc0a51c3aed5c Mon Sep 17 00:00:00 2001 From: billy clark Date: Wed, 12 Jan 2022 19:37:31 -0500 Subject: [PATCH 10/10] Integrate SIL's shared github action for kubectl (#1275) --- .github/workflows/deployment-staging.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/deployment-staging.yml b/.github/workflows/deployment-staging.yml index cc8a4ded5d..d091c8c2ed 100644 --- a/.github/workflows/deployment-staging.yml +++ b/.github/workflows/deployment-staging.yml @@ -54,11 +54,6 @@ jobs: steps: - - name: Install kubectl - run: | - curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" - sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl - kubectl version + uses: sillsdev/common-github-actions/install-kubectl@v1 - - name: Deploy to staging run: kubectl --context ${{ secrets.LTOPS_K8S_STAGING_CONTEXT }} set image deployment/app app=${{ needs.build.outputs.IMAGE }}