Update dev tools config #2229
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for comment on PR, follow instruction for: https://github.com/marketplace/actions/sticky-pull-request-comment | |
name: PRISM CI | |
on: | |
# Run on all pull requests and on pushes to master. | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
frontend_tests: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
name: frontend_tests | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: | | |
**/node_modules | |
**/.eslintcache | |
${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/frontend/yarn.lock') }}-${{ hashFiles('**/common/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies if needed. | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
run: | | |
cd frontend | |
yarn install --frozen-lockfile --network-timeout 100000 | |
yarn setup:common | |
- name: yarn lint | |
run: cd frontend && yarn lint | |
- name: yarn test | |
run: cd frontend && yarn test | |
- name: json check | |
run: cd frontend && yarn prettier:json-check | |
frontend_build_and_deploy: | |
needs: frontend_tests | |
if: github.event_name == 'pull_request' | |
name: frontend_build_and_deploy | |
runs-on: ubuntu-latest | |
env: | |
surge_url: prism-${{ github.event.pull_request.number }}.surge.sh | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: | | |
**/node_modules | |
**/.eslintcache | |
${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/frontend/yarn.lock') }}-${{ hashFiles('**/common/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies if needed. | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
run: | | |
cd frontend | |
yarn install --frozen-lockfile | |
yarn setup:common | |
- name: Find country variable | |
id: country_regex | |
uses: actions-ecosystem/action-regex-match@v2 | |
with: | |
text: ${{ github.event.pull_request.title }} | |
regex: 'COUNTRY=(\w+)' | |
- name: Echo country variable | |
run: echo "Country env is ${{ steps.country_regex.outputs.group1 }}" | |
- name: build frontend | |
run: | | |
cd frontend | |
GENERATE_SOURCEMAP=false REACT_APP_COUNTRY=${{ steps.country_regex.outputs.group1 || 'mozambique'}} yarn build | |
- name: Deploy on surge | |
uses: dswistowski/surge-sh-action@v1 | |
with: | |
domain: ${{ env.surge_url }} | |
project: "frontend/build/." | |
login: ${{ secrets.surge_login }} | |
token: ${{ secrets.surge_token }} | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%dT%H:%M:%S')" | |
- name: Comment PR | |
uses: marocchino/sticky-pull-request-comment@v1 | |
continue-on-error: true | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
message: | | |
Build succeeded and deployed at https://${{ env.surge_url }} | |
(hash ${{ github.event.pull_request.head.sha }} deployed at ${{ steps.date.outputs.date }}) | |
master_frontend_build_and_deploy: | |
needs: frontend_tests | |
if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
name: master_frontend_build_and_deploy | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
country: [mozambique, cambodia, rbd] | |
env: | |
REACT_APP_SENTRY_URL: ${{ secrets.REACT_APP_SENTRY_URL }} | |
surge_url: prism-master-${{ matrix.country }}.surge.sh | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Use Node.js 16.x | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v2 | |
id: yarn-cache | |
with: | |
path: | | |
**/node_modules | |
**/.eslintcache | |
${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/frontend/yarn.lock') }}-${{ hashFiles('**/common/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install dependencies if needed. | |
if: steps.yarn-cache.outputs.cache-hit != 'true' | |
run: | | |
cd frontend | |
yarn install --frozen-lockfile | |
yarn setup:common | |
- name: build frontend | |
run: | | |
cd frontend | |
GENERATE_SOURCEMAP=false REACT_APP_COUNTRY=${{ matrix.country }} yarn build | |
- name: Deploy on surge | |
uses: dswistowski/surge-sh-action@v1 | |
with: | |
domain: ${{ env.surge_url }} | |
project: "frontend/build/." | |
login: ${{ secrets.surge_login }} | |
token: ${{ secrets.surge_token }} | |
api_lint: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.10"] | |
# run the matrix jobs one after the other, so they can benefit from caching | |
max-parallel: 1 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
# Version of Poetry to use | |
version: 1.6.1 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Install dependencies | |
run: | | |
cd api | |
poetry install | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
- name: Check formatting with black and isort | |
run: | | |
cd api | |
poetry run black --check . | |
poetry run isort --check . | |
api_build: | |
name: build and test api | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Docker Compose | |
run: | | |
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker} | |
mkdir -p $DOCKER_CONFIG/cli-plugins | |
curl -SL https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-`uname -s`-`uname -m` -o $DOCKER_CONFIG/cli-plugins/docker-compose | |
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose | |
docker compose version | |
- name: Build containers | |
run: cd api && make build | |
- name: Run tests | |
run: cd api && make api-test |