views folder organised #52
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: CI && CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
run-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v2 | |
- name: Install Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" | |
- name: Install npm dependencies | |
run: npm ci | |
- name: Build and start Docker containers | |
run: | | |
docker-compose -f docker-compose.yml up -d --build | |
sleep 10 # Wait for containers to start | |
- name: Run database migrations | |
run: | | |
docker-compose exec -T app npx sequelize-cli db:drop | |
docker-compose exec -T app npx sequelize-cli db:create | |
docker-compose exec -T app npx sequelize-cli db:migrate | |
- name: Run unit tests | |
run: | | |
docker-compose exec -T app npm test | |
- name: Run integration tests | |
run: | | |
docker-compose exec -T app npm install cypress cypress-json-results | |
docker-compose exec -T app npx cypress run | |
- name: Notify on success | |
if: success() | |
run: | | |
curl -X POST -H 'Content-type: application/json' \ | |
--data '{"text":"🎉🎉🎉 Success! The CI & CD pipeline has completed without issues. All tests passed. :tada:"}' \ | |
${{ secrets.SLACK_URL }} | |
- name: Notify on failure | |
if: failure() | |
run: | | |
curl -X POST -H 'Content-type: application/json' \ | |
--data '{"text":"🚨🚨🚨 Alert! The CI & CD pipeline has encountered problems and failed. Immediate review is required. :warning:"}' \ | |
${{ secrets.SLACK_URL }} | |
- name: Shut down Docker containers | |
run: docker-compose down |