From 9215e6e098b0d6f237a53088e1c405f548b8ca46 Mon Sep 17 00:00:00 2001 From: Ghanem <37152329+AbdulrhmnGhanem@users.noreply.github.com> Date: Fri, 12 Apr 2024 13:55:53 +0200 Subject: [PATCH] Switch to go-gitea docker image (#629) --- docker-compose.deploy.yml | 1 - docker-compose.override.yml | 5 ----- docker-compose.yml | 1 + e2e/cypress/support/commands.js | 2 +- processor/src/giteaDB.ts | 21 ++------------------- processor/src/healthChecks.ts | 3 ++- scripts/importBoardsTxt.ts | 10 +++++----- 7 files changed, 11 insertions(+), 32 deletions(-) diff --git a/docker-compose.deploy.yml b/docker-compose.deploy.yml index ed3a59a728..15878ba308 100644 --- a/docker-compose.deploy.yml +++ b/docker-compose.deploy.yml @@ -8,7 +8,6 @@ services: restart: always gitea: - image: ghcr.io/kitspace/gitea${GITEA_DEPLOY_IMAGE_TAG} command: /usr/bin/entrypoint restart: always ports: diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 3dc059557f..6294ba3e7c 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -20,16 +20,11 @@ services: command: /bin/sh --verbose -c 'yarn install && yarn dev' gitea: - build: - context: gitea - dockerfile: Dockerfile.gitea.dev ports: - '3333:3000' - '2222:22' volumes: - ./gitea:/go/src/code.gitea.io/gitea - # => gitea/docker/root/usr/bin/kitspace_dev_entrypoint - entrypoint: ['/usr/bin/kitspace_dev_entrypoint'] postgres: ports: diff --git a/docker-compose.yml b/docker-compose.yml index 6f71459c5e..c76e4cea8d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -13,6 +13,7 @@ services: - gitea gitea: + image: gitea/gitea:1.21 environment: - ROOT_URL=${KITSPACE_SCHEME}://gitea.${KITSPACE_DOMAIN}${KITSPACE_EXTERNAL_PORT}/ - USER_UID=1000 diff --git a/e2e/cypress/support/commands.js b/e2e/cypress/support/commands.js index 243f8a3df4..67c9a3f1c1 100644 --- a/e2e/cypress/support/commands.js +++ b/e2e/cypress/support/commands.js @@ -75,7 +75,7 @@ Cypress.Commands.add('importRepo', (remoteUrl, repoName, user) => { method: 'GET', failOnStatusCode: false, }) - .then(response => response.body.empty !== false), + .then(response => response.body.empty === false), { timeout: 60_000, interval: 1000 }, ) }) diff --git a/processor/src/giteaDB.ts b/processor/src/giteaDB.ts index 164c8a1eb4..ba2c527b69 100644 --- a/processor/src/giteaDB.ts +++ b/processor/src/giteaDB.ts @@ -67,21 +67,12 @@ export async function waitForNonEmpty(repoId: string): Promise { */ export async function waitForRepoMigration(repoId: string): Promise { const rows = - await sql`SELECT EXISTS (SELECT 1 FROM task WHERE repo_id=${repoId} AND - type=${TaskType.Migration} AND status=${MigrationStatus.Done})` + await sql`SELECT EXISTS (SELECT 1 FROM mirror WHERE repo_id=${repoId})` if (rows[0]?.exists) { return } - - await once( - 'update:task', - row => - row.repo_id === repoId && - row.type === TaskType.Migration && - row.status === MigrationStatus.Done && - row.default_branch !== '', - ) + await once('update:mirror', row => row.repo_id === repoId) } /** @@ -121,10 +112,6 @@ export interface RepoInfo { description: string } -enum TaskType { - Migration = 0, -} - export enum Operation { // https://github.com/porsager/postgres#operation-------schema--table--primary_key Insert = 'insert', @@ -132,7 +119,3 @@ export enum Operation { Delete = 'delete', All = '*', } - -enum MigrationStatus { - Done = 4, -} diff --git a/processor/src/healthChecks.ts b/processor/src/healthChecks.ts index 770c79843b..9fcc6dd11d 100644 --- a/processor/src/healthChecks.ts +++ b/processor/src/healthChecks.ts @@ -13,7 +13,8 @@ export async function checkPartInfoHealth() { }, }) if (res.status !== 200) { - throw new Error(`${endpoint} health check failed with status ${res.status}`) + log.error(`${endpoint} health check failed with status ${res.status}`) + // throw new Error(`${endpoint} health check failed with status ${res.status}`) } else { log.debug(`${endpoint} health check passed`) } diff --git a/scripts/importBoardsTxt.ts b/scripts/importBoardsTxt.ts index c940b22e2e..1296daaab7 100755 --- a/scripts/importBoardsTxt.ts +++ b/scripts/importBoardsTxt.ts @@ -161,7 +161,7 @@ async function mirrorRepo( let message = 'Unknown error' try { message = (await response.json()).message - } catch (e) {} + } catch (e) { } throw new Error( `Failed to mirror ${remoteRepo} to ${user.username}/${repoName}: ${response.status}: ${message}`, ) @@ -187,12 +187,12 @@ async function getAllGithubReposDescriptions( const query = ` query { ${reposOwnerAndName.map( - ([owner, name], index) => ` + ([owner, name], index) => ` r${index}: repository(owner: "${owner}", name: "${name}") { fullName: nameWithOwner description }`, - )} + )} } ` const { data: reposInfo }: GitHubRepoInfoGQLResponse = await fetch( @@ -302,7 +302,7 @@ async function generateGiteaAdminToken() { } const giteaAdminTokenCommand = await exec( - `bash -c "docker exec --user git ${getGiteaContainerCommand.output} /bin/sh -c 'gitea admin user generate-access-token --username ${adminUsername} --raw'"`, + `bash -c "docker exec --user git ${getGiteaContainerCommand.output} /bin/sh -c 'gitea admin user generate-access-token --username ${adminUsername} --raw --scopes write:admin,write:repository,read:admin,read:user'"`, { output: OutputMode.Capture }, ) @@ -310,7 +310,7 @@ async function generateGiteaAdminToken() { throw new Error('Failed to create gitea admin token') } - return giteaAdminTokenCommand.output + return giteaAdminTokenCommand.output.split('\n').at(-1) } type GithubReposDescriptionsMap = Map