feat: init woodpecker #1

Open
realaravinth wants to merge 9 commits from init-woodpecker into master
4 changed files with 28 additions and 9 deletions
Showing only changes of commit fb527d1f33 - Show all commits

View file

@ -1,4 +1,16 @@
steps:
setup:
image: python
when:
event: [push, pull_request, tag, deployment]
environment:
POSTGRES_DATABASE_URL: postgres://postgres:password@database:5432/postgres
commands:
- pip install requests
- sed -i 's/localhost/forgejo/' scripts/gitea.py
- python ./scripts/gitea.py
test:
image: rust
when:
@ -17,7 +29,7 @@ steps:
- make migrate
- make
# - make lint
- make test
- make test.workspaces
build_docker_img:
@ -30,6 +42,9 @@ steps:
tags: latest
services:
forgejo:
image: codeberg.org/forgejo/forgejo:9
database:
image: postgres
environment:

View file

@ -131,6 +131,10 @@ test: migrate ## Run tests
$(call cache_bust)
$(call test_workspaces)
test.workspaces:
$(call cache_bust)
$(call test_workspaces)
# cd database/db-sqlx-postgres &&\
# DATABASE_URL=${POSTGRES_DATABASE_URL}\
# cargo test --no-fail-fast

View file

@ -19,5 +19,5 @@ services:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "8080:3000"
- "3000:3000"
- "2221:22"

View file

@ -20,7 +20,7 @@ def check_online():
while True:
try:
res = requests.get(
"http://localhost:8080/api/v1/nodeinfo", allow_redirects=False
"http://localhost:3000/api/v1/nodeinfo", allow_redirects=False
)
if any([res.status_code == 302, res.status_code == 200]):
break
@ -49,7 +49,7 @@ def install():
"domain": "localhost",
"ssh_port": "2221",
"http_port": "3000",
"app_url": "http://localhost:8080/",
"app_url": "http://localhost:3000/",
"log_root_path": "/data/gitea/log",
"smtp_host": "",
"smtp_from": "",
@ -67,7 +67,7 @@ def install():
"admin_confirm_passwd": "",
"admin_email": "",
}
requests.post(f"http://localhost:8080", data=INSTALL_PAYLOAD)
requests.post(f"http://localhost:3000", data=INSTALL_PAYLOAD)
class ParseCSRFGiteaForm(HTMLParser):
@ -118,7 +118,7 @@ class HTMLClient:
def register(client: HTMLClient):
url = "http://localhost:8080/user/sign_up"
url = "http://localhost:3000/user/sign_up"
csrf = client.get_csrf_token(url)
payload = {
"_csrf": csrf,
@ -131,7 +131,7 @@ def register(client: HTMLClient):
def login(client: HTMLClient):
url = "http://localhost:8080/user/login"
url = "http://localhost:3000/user/login"
csrf = client.get_csrf_token(url)
payload = {
"_csrf": csrf,
@ -167,7 +167,7 @@ def create_repositories(client: HTMLClient):
}
return data
url = "http://localhost:8080/repo/create"
url = "http://localhost:3000/repo/create"
for repo in REPOS:
csrf = client.get_csrf_token(url)
resp = client.session.post(url, data=get_repository_payload(csrf, repo))
@ -182,7 +182,7 @@ def create_repositories(client: HTMLClient):
def add_tag(repo: str, client: HTMLClient):
print("adding tags")
tag = "testing"
url = f"http://{GITEA_USER}:{GITEA_PASSWORD}@localhost:8080/api/v1/repos/{GITEA_USER}/{repo}/topics/{tag}"
url = f"http://{GITEA_USER}:{GITEA_PASSWORD}@localhost:3000/api/v1/repos/{GITEA_USER}/{repo}/topics/{tag}"
resp = requests.put(url)
if resp.status_code != 204:
print(f"Error while adding tags repository: {repo} {resp.status_code}")