Skip to content

Merge pull request #1066 from devinit/feature/oecd-apr24-update #3707

Merge pull request #1066 from devinit/feature/oecd-apr24-update

Merge pull request #1066 from devinit/feature/oecd-apr24-update #3707

Workflow file for this run

name: DDW CI
on:
push:
tags:
- "*"
branches:
- "develop"
pull_request:
branches:
- "*"
concurrency: CI
jobs:
test-typescript:
name: 'Test Typescript'
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: |
npm config set '@bit:registry' https://node.bit.dev
npm ci --ignore-scripts --no-optional
npm install -g codecov
- name: Run tests
run: |
npm run lint
npm run coverage:ts
env:
CI: true
test-python:
name: 'Test Python'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: '3.8'
architecture: 'x64'
- uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
pip3 install --user codecov
- name: Run docker build
run: |
docker volume create --name=metadata2
echo "SITE_URL=ddw.devinit.org" >> .env
echo "SPOTLIGHTS_URL=api.devinit.org" >> .env
docker-compose up -d --build
- name: Import CSVs
run: |
docker-compose exec -T web python3 manage.py update_csv_files
- name: Run tests
run: |
npm run coverage:py
env:
CI: true
automerge:
name: Auto Merge Dependabot
needs: [test-typescript,test-python]
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: fastify/[email protected]
with:
github-token: ${{secrets.PA_TOKEN}}
deploy:
name: 'Deploy'
needs: [test-typescript,test-python]
runs-on: ubuntu-latest
if:
contains('
refs/heads/develop
', github.ref) || startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- name: Set env for develop branch
if: endsWith(github.ref, '/develop') || endsWith(github.ref, '-beta')
run: |
echo "HOST=${{ secrets.DEV_HOST }}" >> $GITHUB_ENV
echo "USERNAME=${{ secrets.DEV_USER }}" >> $GITHUB_ENV
echo "SITE_URL=staging-ddw.devinit.org" >> $GITHUB_ENV
echo "SPOTLIGHTS_URL=staging-api.devinit.org" >> $GITHUB_ENV
- name: Set env for release branch
if: startsWith(github.ref, 'refs/tags/v') && !endsWith(github.ref, '-beta')
run: |
echo "HOST=${{ secrets.PROD_HOST }}" >> $GITHUB_ENV
echo "USERNAME=${{ secrets.PROD_USER }}" >> $GITHUB_ENV
echo "SITE_URL=ddw.devinit.org" >> $GITHUB_ENV
echo "SPOTLIGHTS_URL=api.devinit.org" >> $GITHUB_ENV
- name: Get the release version
if: startsWith(github.ref, 'refs/tags/v')
id: get_version
run: echo VERSION=$(echo $GITHUB_REF | cut -d / -f 3) >> $GITHUB_OUTPUT
- name: copy deploy scripts to dev server
if: endsWith(github.ref, '/develop') || endsWith(github.ref, '-beta')
uses: appleboy/[email protected]
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.KEY }}
source: "deploy_script.sh,deploy.sh"
target: "."
- name: copy deploy script to production server
if: startsWith(github.ref, 'refs/tags/v') && !endsWith(github.ref, '-beta')
uses: appleboy/[email protected]
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
port: ${{ secrets.PORT }}
key: ${{ secrets.KEY }}
source: "deploy.sh"
target: "."
- name: ssh into remote dev server for develop branch
if: endsWith(github.ref, '/develop')
uses: appleboy/[email protected]
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
command_timeout: 30m
script: |
chmod 700 "deploy_script.sh"
./deploy_script.sh
- name: ssh into remote dev server for beta tag
if: endsWith(github.ref, '-beta')
uses: appleboy/[email protected]
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
command_timeout: 30m
script: |
version=$(echo ${{ steps.get_version.outputs.VERSION }} | cut -c 2-)
export SITE_URL=${{ env.SITE_URL }}
export SPOTLIGHTS_URL=${{ env.SPOTLIGHTS_URL }}
chmod 700 "deploy.sh"
./deploy.sh $version
- name: ssh into remote production server
if: startsWith(github.ref, 'refs/tags/v') && !endsWith(github.ref, '-beta')
uses: appleboy/[email protected]
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
command_timeout: 30m
script: |
version=$(echo ${{ steps.get_version.outputs.VERSION }} | cut -c 2-)
export SITE_URL=${{ env.SITE_URL }}
export SPOTLIGHTS_URL=${{ env.SPOTLIGHTS_URL }}
chmod 700 "deploy.sh"
./deploy.sh $version
- name: Build JS
uses: appleboy/[email protected]
with:
host: ${{ env.HOST }}
username: ${{ env.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
command_timeout: 30m
script: |
cd ~/ddw-analyst-ui
npm -v
npm ci --no-optional
npm run build
docker-compose exec -T web python manage.py collectstatic --no-input
end-to-end:
name: 'Cypress End-to-End'
needs: [deploy]
runs-on: ubuntu-latest
if:
contains('
refs/heads/develop
', github.ref) || endsWith(github.ref, '-beta')
strategy:
matrix:
node-version: [16.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: |
npm config set '@bit:registry' https://node.bit.dev
npm ci
- name: Run end-to-end tests
run: |
npm run cy:run-ci
env:
CI: true