forked from MajidBenam/seshat
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from edwardchalstrey1/CI
Add GH actions workflow (docker)
- Loading branch information
Showing
8 changed files
with
122 additions
and
35 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: build_docker_image | ||
|
||
on: | ||
push: | ||
branches: [dev] | ||
paths: | ||
- 'Dockerfile' | ||
pull_request: | ||
branches: [dev] | ||
paths: | ||
- 'Dockerfile' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Login to GitHub Packages | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: docker.pkg.github.com | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GH_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
push: true | ||
tags: docker.pkg.github.com/edwardchalstrey1/seshat/tests-image:latest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
--- | ||
name: Test code | ||
name: test_code | ||
|
||
on: | ||
push: | ||
branches: [develop] | ||
branches: [dev] | ||
pull_request: | ||
branches: [develop] | ||
branches: [dev] | ||
|
||
jobs: | ||
test_core: | ||
strategy: | ||
matrix: | ||
os: ['ubuntu-latest'] | ||
python-version: ['3.8'] | ||
runs-on: ${{ matrix.os }} | ||
runs-on: ['ubuntu-latest'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
- name: Login to GitHub Packages | ||
uses: docker/login-action@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: | ||
Install dependencies | ||
registry: docker.pkg.github.com | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GH_TOKEN }} | ||
- name: Pull and run Docker image | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install "django-geojson [field]" | ||
docker pull docker.pkg.github.com/edwardchalstrey1/seshat/tests-image:latest | ||
docker run -d -p 5432:5432 -v ${{ github.workspace }}:/seshat -e DJANGO_SETTINGS_MODULE=seshat.settings.local -e POSTGRES_PASSWORD=postgres -e PGDATA=/var/lib/postgresql/data/db-files/ -e GITHUB_ACTIONS='true' --name seshat_testing docker.pkg.github.com/edwardchalstrey1/seshat/tests-image:latest | ||
- name: Sleep, then check PostgreSQL connectivity | ||
run: | | ||
sleep 10 | ||
docker exec seshat_testing psql -h localhost -U postgres -c 'SELECT 1' | ||
- name: Run tests | ||
run: | | ||
python manage.py test seshat.apps.core --keepdb | ||
docker exec seshat_testing python3 /seshat/manage.py test seshat.apps.core --keepdb |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM postgis/postgis | ||
|
||
# Update the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories. | ||
RUN apt-get update -y | ||
|
||
# Install the packages | ||
RUN apt-get install -y gdal-bin libgdal-dev libgeos++-dev libgeos-c1v5 libgeos-dev libgeos-doc | ||
|
||
# Install pip | ||
RUN apt-get install -y python3-pip | ||
|
||
# Upgrade pip | ||
RUN python3 -m pip install --upgrade pip | ||
|
||
# Copy requirements.txt file into the Docker image | ||
COPY requirements.txt . | ||
|
||
# Install Python dependencies | ||
RUN pip install -r requirements.txt | ||
|
||
# Install django-geojson | ||
RUN pip install "django-geojson[field]" |
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
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
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
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
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