Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
billy clark committed Jan 20, 2022
2 parents d0543e3 + 8120f77 commit 1173fc9
Show file tree
Hide file tree
Showing 17 changed files with 662 additions and 692 deletions.
13 changes: 10 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,23 @@ Only keep lines below that describe this change, then delete the rest.

Please provide screenshots / animations for any change that involves the UI. Please provide animations to demonstrate user interaction / behavior changes

## How Has This Been Tested?
## Testing on your branch

Please describe the manual tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Please describe how to test and/or verify your changes. Provide instructions so we can reproduce. Please also provide relevant test data as necessary. These instructions will be used for QA testing below.

- [ ] Test A
- [ ] Test B

## Checklist:
## Checklist

- [ ] I have performed a self-review of my own code
- [ ] I have reviewed the title/description of this PR which will be used as the squashed PR commit message
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added tests that prove my fix is effective or that my feature works

## qa.languageforge.org testing

Reviewers: add/replace your name below and check the box to sign-off/attest the feature works as expected on qa.languageforge.org

- [ ] Reviewer1 (YYYY-MM-DD HH:MM)
- [ ] Reviewer2 (YYYY-MM-DD HH:MM)
39 changes: 0 additions & 39 deletions .github/workflows/build-and-deploy-images.yml

This file was deleted.

59 changes: 0 additions & 59 deletions .github/workflows/deployment-staging.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/integrate-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Integrate changes and deploy

# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on:
workflow_call:
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#onworkflow_callinputs
inputs:
image-tag:
type: string
required: true
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_callsecrets
secrets:
kube-context:
required: true
image-repo-username:
required: true
image-repo-password:
required: true

jobs:
integrate:
runs-on: ubuntu-latest

env:
# https://docs.docker.com/develop/develop-images/build_enhancements/
DOCKER_BUILDKIT: 1

defaults:
run:
working-directory: docker

steps:
-
uses: actions/checkout@v2
-
run: |
docker --version
docker-compose --version
-
name: Establish image name
id: image
run: |
echo ::set-output name=NAMESPACE::sillsdev/web-languageforge
echo ::set-output name=TAG::${{ inputs.image-tag }}
-
name: Build app
run: docker-compose build --build-arg ENVIRONMENT=production --build-arg BUILD_VERSION=${{ steps.image.outputs.TAG }} app
-
run: docker-compose run --rm app cat /var/www/html/build-version.txt /var/www/html/version.php
-
name: Check unit tests
run: make unit-tests-ci
-
name: Check e2e tests
run: make e2e-tests-ci
-
name: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.image-repo-username }}
password: ${{ secrets.image-repo-password }}
-
name: Tag image
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 }}

outputs:
IMAGE: ${{ steps.image.outputs.NAMESPACE }}:${{ steps.image.outputs.TAG }}

deploy:
runs-on: [self-hosted, languageforge]

needs: integrate

steps:
-
uses: sillsdev/common-github-actions/install-kubectl@v1
-
run: kubectl --context ${{ secrets.kube-context }} set image deployment/app app=${{ needs.integrate.outputs.IMAGE }}
21 changes: 21 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Deploy to production

# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on:
push:
tags:
- v*

jobs:
staging:
if: github.event.base_ref == 'refs/heads/master'

# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses
uses: sillsdev/web-languageforge/.github/workflows/integrate-and-deploy.yml@master
with:
image-tag: $(echo ${{ github.ref }} | sed 's/refs\/tags\///')
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idsecrets
secrets:
kube-context: ${{ secrets.LTOPS_K8S_PRODUCTION_CONTEXT }}
image-repo-username: ${{ secrets.DOCKERHUB_USERNAME }}
image-repo-password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Deploy to staging

# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on:
push:
branches:
- develop

jobs:
staging:
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_iduses
uses: sillsdev/web-languageforge/.github/workflows/integrate-and-deploy.yml@develop
with:
image-tag: develop-$(date +%Y%m%d)-${{ github.sha }}
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idsecrets
secrets:
kube-context: ${{ secrets.LTOPS_K8S_STAGING_CONTEXT }}
image-repo-username: ${{ secrets.DOCKERHUB_USERNAME }}
image-repo-password: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
53 changes: 53 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Tests

# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
on:
pull_request:

defaults:
run:
shell: bash
working-directory: docker

env:
DOCKER_BUILDKIT: 1

jobs:
unit-tests:
runs-on: ubuntu-latest

steps:
-
uses: actions/checkout@v2
-
name: Run Unit Tests
run: make unit-tests-ci
-
name: Publish Test Results
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
if: always()
with:
check_name: Unit Test Results
github_token: ${{ github.token }}
files: docker/PhpUnitTests.xml

e2e-tests:
runs-on: ubuntu-latest

steps:
-
uses: actions/checkout@v2
-
name: Build app
run: make build
-
name: Run E2E Tests
run: make e2e-tests-ci
-
name: Publish Test Results
uses: docker://ghcr.io/enricomi/publish-unit-test-result-action:v1
if: always()
with:
check_name: E2E Test Results
github_token: ${{ github.token }}
files: docker/e2e-results.xml
21 changes: 0 additions & 21 deletions .github/workflows/unit-tests.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PhpUnitTests.xml
docker/e2e-results.xml
src/assets/*
!src/assets/.gitkeep
src/cache/*
Expand Down
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,6 @@ After a minute or two, your source or test changes should be applied and you sho

1. `make dev` will start the app in development mode, i.e. changes to source code will immediately be reflected in the locally running app.

### Building for deployment

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

Visual Studio Code is a simple, free, cross-platform code editor. You can download VS Code from [here](https://code.visualstudio.com/).
Expand Down Expand Up @@ -237,24 +233,26 @@ To debug the tests:
- To debug in VSCode, select the "Node debugger" debug configuration and run it.

## Application deployment ##
Language Forge is built to run in a containerized environment. For now, Kubernetes is the chosen runtime platform. Deployments are not currently automated and must be manually run with the appropriate credentials or from within our CD platform, TeamCity at this time. Deployment scripts for k8s can be found in `docker/deployment`
Language Forge is built to run in a containerized environment. For now, Kubernetes is the chosen runtime platform. Deployments are automated under the right circumstances using GitHub Actions.

### Staging (QA) ###
Staging deployments can be run with `VERSION=<some-docker-tag-or-semver> make deploy-staging`.
Staging deployments can be manually run with `VERSION=<some-docker-tag-or-semver> make deploy-staging`.

Current workflow:
1. merge commits into or make commits on `develop` branch
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.
1. merge PR into or make commits on `develop` branch
1. this will kick off the GHA (`.github/workflows/staging.yml`) to build, test and publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) and deploy this code to the staging environment at https://qa.languageforge.org

### Production ###
Production deployments can be run with `VERSION=<some-docker-tag-or-semver> make deploy-prod`.
Production deployments can be manually run with `VERSION=<some-docker-tag-or-semver> make deploy-prod`.

Current workflow:
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)
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/production.yml`) to build, test and publish the necessary images to Docker Hub (https://hub.docker.com/r/sillsdev/web-languageforge/tags) and deploy this code to the production environment at https://languageforge.org

### Revert ###
Various tagged images are maintained in Docker Hub. If you need to revert to a previous version, you can do so by running the deployments scripts with the appropriate permissions or utilizing the Kubernetes UI to change the image of a deployment at any time.

### Backup/Restore ###
Backups will be established automatically by LTOps and utilized by LF through the `storageClassName` property in a Persistent Volume Claim. This storage class provided by LTOps establishes both a frequency and retention for a backup. Any time a restoration is needed, the LF team will need to coordinate the effort with LTOps. The process of restoring from a point in time will require the application be brought down for maintenance. The process will roughly follow these steps:
Expand Down
Loading

0 comments on commit 1173fc9

Please sign in to comment.