Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: trigger new release #60

Closed
wants to merge 11 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .flake8

This file was deleted.

130 changes: 74 additions & 56 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,67 +1,85 @@
name: CI
on:
pull_request:
branches:
- "*"
push:
branches:
- main
- develop
tags:
- "v*"
pull_request:
branches:
- "*"
push:
branches:
- main
- develop
tags:
- "v*"

env:
IMAGE_NAME: unitystation/unitystation_auth
IMAGE_NAME: unitystation/central-command

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: pre-commit/[email protected]

test:
needs: [lint]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: |
docker pull $IMAGE_NAME
docker build --pull --cache-from $IMAGE_NAME -t $IMAGE_NAME .
- name: Test
env:
COMPOSE_CMD: docker-compose -f test-compose.yml
run: |
$COMPOSE_CMD up -d db
sleep 5 # let db initialize
$COMPOSE_CMD run test migrate
$COMPOSE_CMD run test
unit_test:
needs: [ lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
pip install poetry
poetry config virtualenvs.create false
poetry install
- name: Run tests
env:
SECRET_KEY: secret
DB_ENGINE: django.db.backends.sqlite3
run: |
cd src
python manage.py migrate
python manage.py test

deploy:
needs: [test]
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build image
run: |
docker pull $IMAGE_NAME
docker build --pull --cache-from $IMAGE_NAME -t $IMAGE_NAME:latest .

- name: Log in into Docker Hub
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
build_docker:
needs: [ lint ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: |
docker pull $IMAGE_NAME
docker build --pull --cache-from $IMAGE_NAME -t $IMAGE_NAME .

# Context:
# For some reason, commits from semantic-release bot do not trigger any actions.
# Build/push steps were copied into release workflow until we figure out a better way.
# - name: Add a release tag to image
# if: contains(github.ref, 'refs/tags/')
# run: |
# docker tag $IMAGE_NAME $IMAGE_NAME:${GITHUB_REF#refs/tags/}
deploy:
needs: [ unit_test, build_docker ]
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Build image
run: |
docker pull $IMAGE_NAME
docker build --pull --cache-from $IMAGE_NAME -t $IMAGE_NAME:latest .

- name: Push image to registry
run: |
docker push $IMAGE_NAME
- name: Log in into Docker Hub
run: |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin

# Context:
# For some reason, commits from semantic-release bot do not trigger any actions.
# Build/push steps were copied into release workflow until we figure out a better way.
# - name: Add a release tag to image
# if: contains(github.ref, 'refs/tags/')
# run: |
# docker tag $IMAGE_NAME $IMAGE_NAME:${GITHUB_REF#refs/tags/}

- name: Push image to registry
run: |
docker push $IMAGE_NAME
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
runs-on: ubuntu-latest
needs: [release]
env:
IMAGE_NAME: unitystation/unitystation_auth
IMAGE_NAME: unitystation/central-command
steps:
- uses: actions/checkout@v2
with:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ dmypy.json
# Pyre type checker
.pyre/

# ruff
.ruff_cache

# IDEs
.idea/
.vscode/
Expand All @@ -137,4 +140,4 @@ dmypy.json
DB/

# settings and config files
src/badwords.txt
src/badwords.txt
36 changes: 19 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,32 @@
repos:
- repo: https://github.com/timothycrosley/isort
rev: 5.8.0
hooks:
- id: isort

- repo: https://github.com/ambv/black
rev: 21.5b1
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.270
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
args: ["--allow-multiple-documents"]
- id: debug-statements
- id: trailing-whitespace
exclude: >-
^.*.md$

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: ["flake8-bugbear", "flake8-django"]
# pre-commit passes individual files to linters, flake8-django finds errors in
# migrations folder in this case despite configuration. Until someone finds a
# fix this should be duplicated here and .flake8 config.
exclude: migrations
#
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v0.782
# hooks:
Expand Down
22 changes: 15 additions & 7 deletions Dockerfile
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9-alpine3.13
FROM python:3.10.6-alpine3.16

# enables proper stdout flushing
ENV PYTHONUNBUFFERED yes
Expand Down Expand Up @@ -30,11 +30,19 @@ RUN apk add --no-cache libpq \

COPY src .

RUN addgroup -S unitystation \
&& adduser -S auth_server -G unitystation \
&& chown -R auth_server:unitystation /src
RUN mkdir /home/website
RUN mkdir /home/website/statics
RUN mkdir /home/website/media

USER auth_server
# I'm too dumb to make user permissions over shared volumes work
#RUN addgroup -S unitystation \
# && adduser -S central_command -G unitystation \
# && chown -R central_command:unitystation /src \
# && chown -R central_command:unitystation $home
#
#USER central_command

ENTRYPOINT ["python", "manage.py"]
CMD ["runserver", "0:8000"]
RUN sed -i 's/\r$//g' entrypoint.sh
RUN chmod +x entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# unitystation_auth
![Docker Image Version (latest by date)](https://img.shields.io/docker/v/unitystation/unitystation_auth)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/38cce37d4c854ca48645fd5ecc9cae61)](https://www.codacy.com/gh/unitystation/unitystation_auth/dashboard?utm_source=github.com&utm_medium=referral&utm_content=unitystation/unitystation_auth&utm_campaign=Badge_Grade)
# Central Command
![Docker Image Version (latest by date)](https://img.shields.io/docker/v/unitystation/central-command?sort=date)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/38cce37d4c854ca48645fd5ecc9cae61)](https://www.codacy.com/gh/unitystation/central-command/dashboard?utm_source=github.com&utm_medium=referral&utm_content=unitystation/central-command&utm_campaign=Badge_Grade)

The all-in-one backend application for [Unitystation](https://github.com/unitystation/unitystation)

### Features
- Account managment and user validation.
- Server list managment.
- In-game persistence.
- Works cross-fork!
- Modular architecture.

### Development guide
#### Setting up Docker
Expand Down
20 changes: 20 additions & 0 deletions api-collection/CreateAccount/Invalid identifier.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
meta {
name: Invalid identifier
type: http
seq: 2
}

post {
url: {{baseUrl}}/accounts/register
body: json
auth: none
}

body:json {
{
"account_identifier": "' 'DROP TABLE USERS;",
"username": "My Name",
"password": "qweasd123",
"email": "[email protected]"
}
}
20 changes: 20 additions & 0 deletions api-collection/CreateAccount/Valid.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
meta {
name: Valid
type: http
seq: 1
}

post {
url: {{baseUrl}}/accounts/register
body: json
auth: none
}

body:json {
{
"account_identifier": "myname",
"username": "My Name",
"password": "qweasd123",
"email": "[email protected]"
}
}
18 changes: 18 additions & 0 deletions api-collection/LoginWithCreds/non existent account.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
meta {
name: non existent account
type: http
seq: 3
}

post {
url: {{baseUrl}}/accounts/login-credentials
body: json
auth: none
}

body:json {
{
"email": "[email protected]",
"password": "qweasd123"
}
}
18 changes: 18 additions & 0 deletions api-collection/LoginWithCreds/not verified.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
meta {
name: not verified
type: http
seq: 2
}

post {
url: {{baseUrl}}/accounts/login-credentials
body: json
auth: none
}

body:json {
{
"email": "[email protected]",
"password": "qweasd123"
}
}
18 changes: 18 additions & 0 deletions api-collection/LoginWithCreds/success.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
meta {
name: success
type: http
seq: 1
}

post {
url: {{baseUrl}}/accounts/login-credentials
body: json
auth: none
}

body:json {
{
"email": "[email protected]",
"password": "admin"
}
}
22 changes: 22 additions & 0 deletions api-collection/LoginWithToken/invalid token.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
meta {
name: invalid token
type: http
seq: 3
}

post {
url: {{baseUrl}}/accounts/login-token
body: json
auth: none
}

headers {
Authorization: Token 6dc6178ad72f5beA0581b6b49024cdbb41d85ffdd1fbbf40991cce24a69a327b
}

body:json {
{
"username": "[email protected]",
"password": "admin"
}
}
Loading
Loading