code cleanup #273
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
name: integration-tests | |
on: | |
push: | |
branches: | |
- '**' # matches every branch | |
jobs: | |
integration-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- name: Start the elasticsearch docker container | |
run: | | |
docker run -d -p 9200:9200 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.12.0 | |
echo "127.0.0.1 elasticsearch" | sudo tee -a /etc/hosts | |
- name: Install backend and frontend dependencies | |
run: | | |
pip3 install -r backend/requirements.txt | |
npm i --prefix frontend | |
- name: Start backend and frontend applications in the background | |
run: | | |
python3 backend/main.py & | |
sleep 10 | |
- name: API testing | |
run: | | |
npm run start --prefix frontend & | |
pytest backend --doctest-modules --junitxml=junit/test-results.xml --cov=. --cov-report=xml | |
- name: Cypress End to End testing | |
run: | | |
cd frontend | |
sudo npm install -g --unsafe-perm=true --allow-root cypress | |
sudo cypress run --headless --browser chrome | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
upload-docker-image: | |
needs: integration-tests | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build backend and frontend image | |
run: | | |
npm i --prefix frontend | |
npm run build --prefix frontend | |
docker build --no-cache -t dineshsonachalam/tech-courses-search-engine-backend:latest -f backend.Dockerfile . | |
docker build --no-cache -t dineshsonachalam/tech-courses-search-engine-frontend:latest -f frontend.Dockerfile . | |
- name: Log into registry | |
run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
- name: Push image | |
run: | | |
docker push dineshsonachalam/tech-courses-search-engine-backend:latest | |
docker push dineshsonachalam/tech-courses-search-engine-frontend:latest | |
deploy-to-k8-cluster: | |
needs: upload-docker-image | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- uses: danielr1996/[email protected] | |
name: Backend deployment rolling restart to fetch recently build docker image from docker hub. | |
with: | |
kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }} | |
args: rollout restart deployment search-backend -n=dinesh | |
- uses: danielr1996/[email protected] | |
name: Verify deployment for backend app | |
with: | |
kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }} | |
args: rollout status deployment/search-backend -n=dinesh | |
- uses: danielr1996/[email protected] | |
name: Frontend deployment rolling restart to fetch recently build docker image from docker hub. | |
with: | |
kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }} | |
args: rollout restart deployment search-frontend -n=dinesh | |
- uses: danielr1996/[email protected] | |
name: Verify deployment for frontend app | |
with: | |
kubeconfig: ${{ secrets.KUBE_CONFIG_DATA }} | |
args: rollout status deployment/search-frontend -n=dinesh |