Compare commits
No commits in common. "init-woodpecker" and "master" have entirely different histories.
init-woodp
...
master
9 changed files with 331 additions and 81 deletions
43
.github/workflows/clippy-fmt.yml
vendored
Normal file
43
.github/workflows/clippy-fmt.yml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fmt:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
components: rustfmt
|
||||||
|
- name: Check with rustfmt
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Rust
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
components: clippy
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: Check with Clippy
|
||||||
|
uses: actions-rs/clippy-check@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
args: --workspace --tests --all-features
|
93
.github/workflows/coverage.yml
vendored
Normal file
93
.github/workflows/coverage.yml
vendored
Normal file
|
@ -0,0 +1,93 @@
|
||||||
|
name: Coverage
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable
|
||||||
|
|
||||||
|
# services:
|
||||||
|
# postgres:
|
||||||
|
# image: postgres
|
||||||
|
# env:
|
||||||
|
# POSTGRES_PASSWORD: password
|
||||||
|
# POSTGRES_USER: postgres
|
||||||
|
# POSTGRES_DB: postgres
|
||||||
|
# options: >-
|
||||||
|
# --health-cmd pg_isready
|
||||||
|
# --health-interval 10s
|
||||||
|
# --health-timeout 5s
|
||||||
|
# --health-retries 5
|
||||||
|
# ports:
|
||||||
|
# - 5432:5432
|
||||||
|
|
||||||
|
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
# - name: ⚡ Cache
|
||||||
|
# uses: actions/cache@v3
|
||||||
|
# with:
|
||||||
|
# path: |
|
||||||
|
# ~/.cargo/registry
|
||||||
|
# ~/.cargo/git
|
||||||
|
# target
|
||||||
|
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: load env
|
||||||
|
run: |
|
||||||
|
mkdir -p db/db-sqlx-sqlite/tmp &&
|
||||||
|
source .env-sample \
|
||||||
|
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||||
|
&& echo "SQLITE_DATABASE_URL=$SQLITE_DATABASE_URL" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
# usually run as part of `make test` but because this workflow doesn't run
|
||||||
|
# that command, `make dev-env` is used
|
||||||
|
- name: setup dev environment
|
||||||
|
run: make dev-env
|
||||||
|
env:
|
||||||
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: run migrations
|
||||||
|
run: make migrate
|
||||||
|
env:
|
||||||
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: Generate coverage file
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||||
|
uses: actions-rs/tarpaulin@v0.1
|
||||||
|
env:
|
||||||
|
# GIT_HASH is dummy value. I guess build.rs is skipped in tarpaulin
|
||||||
|
# execution so this value is required for preventing meta tests from
|
||||||
|
# panicking
|
||||||
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61
|
||||||
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
with:
|
||||||
|
args: "--all-features --no-fail-fast --workspace=db/db-sqlx-sqlite,. -t 1200"
|
||||||
|
# args: "--all-features --no-fail-fast --workspace=database/db-sqlx-postgres,database/db-sqlx-sqlite,. -t 1200"
|
||||||
|
|
||||||
|
- name: Upload to Codecov
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
|
||||||
|
uses: codecov/codecov-action@v2
|
128
.github/workflows/linux.yml
vendored
Normal file
128
.github/workflows/linux.yml
vendored
Normal file
|
@ -0,0 +1,128 @@
|
||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types: [opened, synchronize, reopened]
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build_and_test:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
version:
|
||||||
|
- stable
|
||||||
|
# - nightly
|
||||||
|
|
||||||
|
name: ${{ matrix.version }} - x86_64-unknown-linux-gnu
|
||||||
|
runs-on:
|
||||||
|
ubuntu-latest
|
||||||
|
|
||||||
|
# services:
|
||||||
|
# postgres:
|
||||||
|
# image: postgres
|
||||||
|
# env:
|
||||||
|
# POSTGRES_PASSWORD: password
|
||||||
|
# POSTGRES_USER: postgres
|
||||||
|
# POSTGRES_DB: postgres
|
||||||
|
# options: >-
|
||||||
|
# --health-cmd pg_isready
|
||||||
|
# --health-interval 10s
|
||||||
|
# --health-timeout 5s
|
||||||
|
# --health-retries 5
|
||||||
|
# ports:
|
||||||
|
# - 5432:5432
|
||||||
|
#
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# - name: ⚡ Cache
|
||||||
|
# uses: actions/cache@v3
|
||||||
|
# with:
|
||||||
|
# path: |
|
||||||
|
# /var/lib/docker
|
||||||
|
# ~/.cargo/registry
|
||||||
|
# ~/.cargo/git
|
||||||
|
# target
|
||||||
|
# key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
|
||||||
|
|
||||||
|
- name: Cache
|
||||||
|
uses: Swatinem/rust-cache@v1
|
||||||
|
|
||||||
|
- name: Login to DockerHub
|
||||||
|
if: (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'forgeflux-org/starchart'
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Install ${{ matrix.version }}
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: ${{ matrix.version }}-x86_64-unknown-linux-gnu
|
||||||
|
profile: minimal
|
||||||
|
override: true
|
||||||
|
|
||||||
|
- name: load env
|
||||||
|
run: |
|
||||||
|
mkdir -p db/db-sqlx-sqlite/tmp &&
|
||||||
|
source .env-sample \
|
||||||
|
&& echo "POSTGRES_DATABASE_URL=$POSTGRES_DATABASE_URL" >> $GITHUB_ENV \
|
||||||
|
&& echo "SQLITE_DATABASE_URL=$SQLITE_DATABASE_URL" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: run migrations
|
||||||
|
run: make migrate
|
||||||
|
env:
|
||||||
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: build
|
||||||
|
run:
|
||||||
|
make
|
||||||
|
env:
|
||||||
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: build docker images
|
||||||
|
if: matrix.version == 'stable'
|
||||||
|
run: make docker
|
||||||
|
|
||||||
|
- name: publish docker images
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'forgeflux-org/starchart'
|
||||||
|
run: make docker-publish
|
||||||
|
|
||||||
|
- name: run tests
|
||||||
|
timeout-minutes: 40
|
||||||
|
run:
|
||||||
|
make test
|
||||||
|
env:
|
||||||
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: generate documentation
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'forgeflux-org/starchart'
|
||||||
|
run:
|
||||||
|
make doc
|
||||||
|
env:
|
||||||
|
GIT_HASH: 8e77345f1597e40c2e266cb4e6dee74888918a61 # dummy value
|
||||||
|
POSTGRES_DATABASE_URL: "${{ env.POSTGRES_DATABASE_URL }}"
|
||||||
|
SQLITE_DATABASE_URL: "${{ env.SQLITE_DATABASE_URL }}"
|
||||||
|
|
||||||
|
- name: Deploy to GitHub Pages
|
||||||
|
if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'push') && github.repository == 'forgeflux-org/starchart'
|
||||||
|
uses: JamesIves/github-pages-deploy-action@3.7.1
|
||||||
|
with:
|
||||||
|
branch: gh-pages
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
FOLDER:
|
||||||
|
./target/doc/
|
||||||
|
|
||||||
|
# - name: deploy
|
||||||
|
# if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'realaravinth/realaravinth' }}
|
||||||
|
# run: >-
|
||||||
|
# curl --location --request POST "https://deploy.batsense.net/api/v1/update" --header 'Content-Type: application/json' --data-raw "{ \"secret\": \"${{ secrets.DEPLOY_TOKEN }}\", \"branch\": \"gh-pages\" }"
|
|
@ -1,57 +0,0 @@
|
||||||
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:
|
|
||||||
event: [push, pull_request, tag, deployment]
|
|
||||||
environment:
|
|
||||||
POSTGRES_DATABASE_URL: postgres://postgres:password@database:5432/postgres
|
|
||||||
SQLITE_DATABASE_URL: sqlite:///tmp/admin.db
|
|
||||||
FORGEJO_HOST: http://forgejo:3000
|
|
||||||
commands:
|
|
||||||
# - curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &&\
|
|
||||||
# - apt update && apt-get -y --no-install-recommends install nodejs tar gpg curl wget
|
|
||||||
# - rustup toolchain install nightly
|
|
||||||
# - rustup override set nightly
|
|
||||||
- rustup component add rustfmt
|
|
||||||
- rustup component add clippy
|
|
||||||
# - export FORGEFLUX_server_COOKIE_SECRET=d05604b56ffd0f57200be49313a9e51436ca8f1678b9ffdf8d2602d5e9839f05
|
|
||||||
- make migrate
|
|
||||||
- make
|
|
||||||
# - make lint
|
|
||||||
- make test.workspaces
|
|
||||||
|
|
||||||
|
|
||||||
build_docker_img:
|
|
||||||
image: plugins/docker
|
|
||||||
when:
|
|
||||||
event: [pull_request]
|
|
||||||
settings:
|
|
||||||
dry_run: true
|
|
||||||
repo: forgeflux/starchart
|
|
||||||
tags: latest
|
|
||||||
|
|
||||||
services:
|
|
||||||
forgejo:
|
|
||||||
image: codeberg.org/forgejo/forgejo:9
|
|
||||||
environment:
|
|
||||||
FORGEJO__security__INSTALL_LOCK: true
|
|
||||||
FORGEJO__federation__ENABLED: true
|
|
||||||
FORGEJO__server__ROOT_URL: http://forgejo
|
|
||||||
FORGEJO__server__HTTP_PORT: 3000
|
|
||||||
|
|
||||||
database:
|
|
||||||
image: postgres
|
|
||||||
environment:
|
|
||||||
POSTGRES_PASSWORD: password
|
|
4
Makefile
4
Makefile
|
@ -131,10 +131,6 @@ test: migrate ## Run tests
|
||||||
$(call cache_bust)
|
$(call cache_bust)
|
||||||
$(call test_workspaces)
|
$(call test_workspaces)
|
||||||
|
|
||||||
test.workspaces:
|
|
||||||
$(call cache_bust)
|
|
||||||
$(call test_workspaces)
|
|
||||||
|
|
||||||
# cd database/db-sqlx-postgres &&\
|
# cd database/db-sqlx-postgres &&\
|
||||||
# DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
# DATABASE_URL=${POSTGRES_DATABASE_URL}\
|
||||||
# cargo test --no-fail-fast
|
# cargo test --no-fail-fast
|
||||||
|
|
|
@ -5,12 +5,19 @@ networks:
|
||||||
external: false
|
external: false
|
||||||
|
|
||||||
services:
|
services:
|
||||||
forgejo:
|
server:
|
||||||
image: codeberg.org/forgejo/forgejo:9
|
image: gitea/gitea:1.16.5
|
||||||
|
container_name: gitea
|
||||||
environment:
|
environment:
|
||||||
- FORGEJO__security__INSTALL_LOCK=true
|
- USER_UID=1000
|
||||||
- FORGEJO__federation__ENABLED=true
|
- USER_GID=1000
|
||||||
- FORGEJO__server__ROOT_URL=http://localhost
|
restart: always
|
||||||
- FORGEJO__server__HTTP_PORT=3000
|
networks:
|
||||||
|
- gitea
|
||||||
|
volumes:
|
||||||
|
- ./tmp/gitea:/data
|
||||||
|
- /etc/timezone:/etc/timezone:ro
|
||||||
|
- /etc/localtime:/etc/localtime:ro
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "8080:3000"
|
||||||
|
- "2221:22"
|
||||||
|
|
|
@ -31,7 +31,6 @@ pub mod schema;
|
||||||
const REPO_SEARCH_PATH: &str = "/api/v1/repos/search";
|
const REPO_SEARCH_PATH: &str = "/api/v1/repos/search";
|
||||||
const GITEA_NODEINFO: &str = "/api/v1/nodeinfo";
|
const GITEA_NODEINFO: &str = "/api/v1/nodeinfo";
|
||||||
const GITEA_IDENTIFIER: &str = "gitea";
|
const GITEA_IDENTIFIER: &str = "gitea";
|
||||||
const FORGEJO_IDENTIFIER: &str = "forgejo";
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Gitea {
|
pub struct Gitea {
|
||||||
|
@ -178,13 +177,13 @@ mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
pub const GITEA_HOST: &str = "http://localhost:8080";
|
||||||
pub const NET_REPOSITORIES: u64 = 100;
|
pub const NET_REPOSITORIES: u64 = 100;
|
||||||
pub const PER_CRAWL: u64 = 10;
|
pub const PER_CRAWL: u64 = 10;
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn gitea_works() {
|
async fn gitea_works() {
|
||||||
let ctx = Gitea::new(Url::parse(&std::env::var("FORGEJO_HOST").unwrap()).unwrap(), Client::new());
|
let ctx = Gitea::new(Url::parse(GITEA_HOST).unwrap(), Client::new());
|
||||||
|
|
||||||
assert!(ctx.is_forge().await);
|
assert!(ctx.is_forge().await);
|
||||||
let steps = NET_REPOSITORIES / PER_CRAWL;
|
let steps = NET_REPOSITORIES / PER_CRAWL;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ def check_online():
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
res = requests.get(
|
res = requests.get(
|
||||||
"http://localhost:3000/api/v1/nodeinfo", allow_redirects=False
|
"http://localhost:8080/api/v1/nodeinfo", allow_redirects=False
|
||||||
)
|
)
|
||||||
if any([res.status_code == 302, res.status_code == 200]):
|
if any([res.status_code == 302, res.status_code == 200]):
|
||||||
break
|
break
|
||||||
|
@ -30,6 +30,46 @@ def check_online():
|
||||||
count += 1
|
count += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
def install():
|
||||||
|
INSTALL_PAYLOAD = {
|
||||||
|
"db_type": "sqlite3",
|
||||||
|
"db_host": "localhost:3306",
|
||||||
|
"db_user": "root",
|
||||||
|
"db_passwd": "",
|
||||||
|
"db_name": "gitea",
|
||||||
|
"ssl_mode": "disable",
|
||||||
|
"db_schema": "",
|
||||||
|
"charset": "utf8",
|
||||||
|
"db_path": "/data/gitea/gitea.db",
|
||||||
|
"app_name": "Gitea:+Git+with+a+cup+of+tea",
|
||||||
|
"repo_root_path": "/data/git/repositories",
|
||||||
|
"lfs_root_path": "/data/git/lfs",
|
||||||
|
"run_user": "git",
|
||||||
|
"domain": "localhost",
|
||||||
|
"ssh_port": "2221",
|
||||||
|
"http_port": "3000",
|
||||||
|
"app_url": "http://localhost:8080/",
|
||||||
|
"log_root_path": "/data/gitea/log",
|
||||||
|
"smtp_host": "",
|
||||||
|
"smtp_from": "",
|
||||||
|
"smtp_user": "",
|
||||||
|
"smtp_passwd": "",
|
||||||
|
"enable_federated_avatar": "on",
|
||||||
|
"enable_open_id_sign_in": "on",
|
||||||
|
"enable_open_id_sign_up": "on",
|
||||||
|
"default_allow_create_organization": "on",
|
||||||
|
"default_enable_timetracking": "on",
|
||||||
|
"no_reply_address": "noreply.localhost",
|
||||||
|
"password_algorithm": "pbkdf2",
|
||||||
|
"admin_name": "",
|
||||||
|
"admin_passwd": "",
|
||||||
|
"admin_confirm_passwd": "",
|
||||||
|
"admin_email": "",
|
||||||
|
}
|
||||||
|
requests.post(f"http://localhost:8080", data=INSTALL_PAYLOAD)
|
||||||
|
|
||||||
|
|
||||||
class ParseCSRFGiteaForm(HTMLParser):
|
class ParseCSRFGiteaForm(HTMLParser):
|
||||||
token: str = None
|
token: str = None
|
||||||
|
|
||||||
|
@ -70,7 +110,7 @@ class HTMLClient:
|
||||||
|
|
||||||
def get_csrf_token(self, url: str) -> str:
|
def get_csrf_token(self, url: str) -> str:
|
||||||
resp = self.session.get(url, allow_redirects=False)
|
resp = self.session.get(url, allow_redirects=False)
|
||||||
if resp.status_code != 200 and resp.status_code != 302 and resp.status_code != 303:
|
if resp.status_code != 200 and resp.status_code != 302:
|
||||||
print(resp.status_code, resp.text)
|
print(resp.status_code, resp.text)
|
||||||
raise Exception(f"Can't get csrf token: {resp.status_code}")
|
raise Exception(f"Can't get csrf token: {resp.status_code}")
|
||||||
csrf = self.__get_csrf_token(resp.text)
|
csrf = self.__get_csrf_token(resp.text)
|
||||||
|
@ -78,7 +118,7 @@ class HTMLClient:
|
||||||
|
|
||||||
|
|
||||||
def register(client: HTMLClient):
|
def register(client: HTMLClient):
|
||||||
url = "http://localhost:3000/user/sign_up"
|
url = "http://localhost:8080/user/sign_up"
|
||||||
csrf = client.get_csrf_token(url)
|
csrf = client.get_csrf_token(url)
|
||||||
payload = {
|
payload = {
|
||||||
"_csrf": csrf,
|
"_csrf": csrf,
|
||||||
|
@ -91,7 +131,7 @@ def register(client: HTMLClient):
|
||||||
|
|
||||||
|
|
||||||
def login(client: HTMLClient):
|
def login(client: HTMLClient):
|
||||||
url = "http://localhost:3000/user/login"
|
url = "http://localhost:8080/user/login"
|
||||||
csrf = client.get_csrf_token(url)
|
csrf = client.get_csrf_token(url)
|
||||||
payload = {
|
payload = {
|
||||||
"_csrf": csrf,
|
"_csrf": csrf,
|
||||||
|
@ -101,7 +141,7 @@ def login(client: HTMLClient):
|
||||||
}
|
}
|
||||||
resp = client.session.post(url, data=payload, allow_redirects=False)
|
resp = client.session.post(url, data=payload, allow_redirects=False)
|
||||||
print(f"login {client.session.cookies}")
|
print(f"login {client.session.cookies}")
|
||||||
if resp.status_code == 303:
|
if resp.status_code == 302:
|
||||||
print("User logged in")
|
print("User logged in")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -127,7 +167,7 @@ def create_repositories(client: HTMLClient):
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
url = "http://localhost:3000/repo/create"
|
url = "http://localhost:8080/repo/create"
|
||||||
for repo in REPOS:
|
for repo in REPOS:
|
||||||
csrf = client.get_csrf_token(url)
|
csrf = client.get_csrf_token(url)
|
||||||
resp = client.session.post(url, data=get_repository_payload(csrf, repo))
|
resp = client.session.post(url, data=get_repository_payload(csrf, repo))
|
||||||
|
@ -142,7 +182,7 @@ def create_repositories(client: HTMLClient):
|
||||||
def add_tag(repo: str, client: HTMLClient):
|
def add_tag(repo: str, client: HTMLClient):
|
||||||
print("adding tags")
|
print("adding tags")
|
||||||
tag = "testing"
|
tag = "testing"
|
||||||
url = f"http://{GITEA_USER}:{GITEA_PASSWORD}@localhost:3000/api/v1/repos/{GITEA_USER}/{repo}/topics/{tag}"
|
url = f"http://{GITEA_USER}:{GITEA_PASSWORD}@localhost:8080/api/v1/repos/{GITEA_USER}/{repo}/topics/{tag}"
|
||||||
resp = requests.put(url)
|
resp = requests.put(url)
|
||||||
if resp.status_code != 204:
|
if resp.status_code != 204:
|
||||||
print(f"Error while adding tags repository: {repo} {resp.status_code}")
|
print(f"Error while adding tags repository: {repo} {resp.status_code}")
|
||||||
|
@ -156,6 +196,8 @@ if __name__ == "__main__":
|
||||||
REPOS.append(f"repository_{i}")
|
REPOS.append(f"repository_{i}")
|
||||||
check_online()
|
check_online()
|
||||||
print("Instance online")
|
print("Instance online")
|
||||||
|
install()
|
||||||
|
print("Instance configured and installed")
|
||||||
client = HTMLClient()
|
client = HTMLClient()
|
||||||
count = 0
|
count = 0
|
||||||
while True:
|
while True:
|
||||||
|
|
|
@ -229,14 +229,13 @@ mod tests {
|
||||||
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
pub const GITEA_HOST: &str = "http://localhost:8080";
|
||||||
pub const GITEA_USERNAME: &str = "bot";
|
pub const GITEA_USERNAME: &str = "bot";
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
async fn crawl_gitea() {
|
async fn crawl_gitea() {
|
||||||
let (db, ctx, federate, _tmp_dir) = sqlx_sqlite::get_ctx().await;
|
let (db, ctx, federate, _tmp_dir) = sqlx_sqlite::get_ctx().await;
|
||||||
let url = Url::parse(
|
let url = Url::parse(GITEA_HOST).unwrap();
|
||||||
&std::env::var("FORGEJO_HOST").unwrap()
|
|
||||||
).unwrap();
|
|
||||||
ctx.crawl(&url, &db, &federate).await;
|
ctx.crawl(&url, &db, &federate).await;
|
||||||
// let hostname = get_hostname(&Url::parse(GITEA_HOST).unwrap());
|
// let hostname = get_hostname(&Url::parse(GITEA_HOST).unwrap());
|
||||||
assert!(db.forge_exists(&url).await.unwrap());
|
assert!(db.forge_exists(&url).await.unwrap());
|
||||||
|
|
Loading…
Reference in a new issue