Code cleaning up and renaming #1964
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
name: ci | |
on: [pull_request] | |
jobs: | |
format_python_code: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: "recursive" | |
ref: ${{ github.ref }} | |
- name: Blacken Python code | |
uses: jpetrucciani/black-check@master | |
with: | |
path: "." | |
black_flags: "--safe --verbose --diff" | |
build: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, '[ci skip]')" | |
env: | |
RUNNER_ALLOW_RUNASROOT: true | |
services: | |
db: | |
image: postgres:13 | |
ports: | |
- 5432:5432 | |
env: | |
POSTGRES_DB: postgres | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd "pg_isready -U postgres" | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
submodules: "recursive" | |
- name: Make envfile | |
run: | | |
touch .env | |
echo DB_ENGINE=django.db.backends.postgresql >> .env | |
echo DB_HOST=localhost >> .env | |
echo DB_NAME=postgres >> .env | |
echo DB_PORT=5432 >> .env | |
echo DB_PASSWORD=postgres >> .env | |
echo DB_USER=postgres >> .env | |
echo "SECRET_KEY=${{ secrets.SECRET_KEY }}" >> .env | |
echo DEBUG=True >> .env | |
echo ALLOWED_HOSTS=['localhost'] >> .env | |
- name: Build the docker image | |
working-directory: ./app | |
run: docker build -f api/Dockerfile -t ccom-build:latest . | |
- name: Run the docker image | |
run: | | |
#startup the stack | |
docker run -it --env-file .env -p 8080:8000 -d ccom-build:latest | |
#give it 30s to start properly | |
sleep 30s | |
#get container ID | |
containerid=$(docker ps | awk 'NR==2' | awk '{print $1;}') | |
echo $containerid | |
#check the logs for errors | |
if docker logs $containerid | grep -i -q ERROR ; then | |
#print the errors before causing a fail | |
docker logs $containerid | grep -i ERROR | |
echo "Errors found" | |
exit 1 | |
else | |
echo "No errors found!" | |
fi | |
echo "ended if" | |
#put the logs into a file | |
docker logs $containerid >> logs.out | |
#shutdown the container | |
docker stop $containerid | |
#save the logs so they can be further checked | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: my-artifact | |
path: logs.out | |
retention-days: 1 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "20" | |
- name: Install dependencies and build Next.js app | |
run: | | |
npm install | |
npm run build | |
working-directory: app/next-client-app |