From 6a65ca7e2c9f94ab9bf908ef4fb500f14003f9ad Mon Sep 17 00:00:00 2001 From: menduz Date: Thu, 2 Feb 2023 13:27:37 -0300 Subject: [PATCH] add manual conversion workflow --- .github/workflows/manual-build-conversion.yml | 70 +++++++++++++++++++ consumer-server/src/test-conversion.ts | 14 +++- 2 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/manual-build-conversion.yml diff --git a/.github/workflows/manual-build-conversion.yml b/.github/workflows/manual-build-conversion.yml new file mode 100644 index 00000000..722dee52 --- /dev/null +++ b/.github/workflows/manual-build-conversion.yml @@ -0,0 +1,70 @@ +name: Run build & manual conversion + +on: + workflow_dispatch: + inputs: + baseUrl: + required: true + default: "https://peer.decentraland.org/content" + type: string + description: "Content server baseUrl" + pointer: + required: true + default: "urn:decentraland:off-chain:base-avatars:brown_pants" + type: string + description: "Pointer or entity to convert" + build: + type: boolean + default: false + description: "Build image before converting" + +jobs: + main: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + lfs: true + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build image + id: docker_build + if: ${{ inputs.build }} + uses: docker/build-push-action@v3 + with: + context: . + push: false + tags: quay.io/decentraland/asset-bundle-converter:next,quay.io/decentraland/asset-bundle-converter:${{ github.sha }} + load: true + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + COMMIT_HASH=${{ github.sha }} + + - name: Create $(pwd)/tmp/Unity/Unity_lic.ulf + run: mkdir -p $(pwd)/tmp/Unity && echo "$UNITY_2021_ULF" > $(pwd)/tmp/Unity/Unity_lic.ulf + env: + UNITY_2021_ULF: ${{ secrets.UNITY_2021_ULF }} + + - name: Run conversion + run: | + mkdir -p /artifact && + docker run \ + -v $(pwd)/artifact:/artifact \ + -v $(pwd)/tmp/Unity:/root/.local/share/unity3d/Unity \ + quay.io/decentraland/asset-bundle-converter@${{ inputs.build && steps.docker_build.outputs.digest || 'next' }} \ + node --trace-warnings --abort-on-uncaught-exception --unhandled-rejections=strict dist/test-conversion.js \ + --baseUrl ${{ inputs.baseUrl }} \ + --pointer ${{ inputs.pointer }} \ + --outDir /artifact \ + --logFile /artifact/log.txt + + - uses: actions/upload-artifact@v3 + with: + name: ${{ inputs.pointer }} + path: | + /artifact/**/* \ No newline at end of file diff --git a/consumer-server/src/test-conversion.ts b/consumer-server/src/test-conversion.ts index 3b680dba..97258b60 100644 --- a/consumer-server/src/test-conversion.ts +++ b/consumer-server/src/test-conversion.ts @@ -7,6 +7,7 @@ import { createFetchComponent } from './adapters/fetch' import { getEntities } from './logic/fetch-entity-by-pointer' import { createLogComponent } from '@well-known-components/logger' +import { IPFSv1, IPFSv2 } from '@dcl/schemas' import { runConversion } from './logic/run-conversion' import { spawn } from 'child_process' import { closeSync, openSync } from 'fs' @@ -41,9 +42,16 @@ async function main() { const fetcher = await createFetchComponent() const logs = await createLogComponent({}) - const entities = await getEntities(fetcher, [POINTER], BASE_URL) - if (!entities.length) throw new Error(`Cannot find pointer ${POINTER} in server ${BASE_URL}`) + let entityId = '' + + if (IPFSv2.validate(POINTER) || IPFSv1.validate(POINTER)) { + entityId = POINTER + } else { + const entities = await getEntities(fetcher, [POINTER], BASE_URL) + if (!entities.length) throw new Error(`Cannot find pointer ${POINTER} in server ${BASE_URL}`) + entityId = entities[0].id + } const logger = logs.getLogger('test-logger') @@ -57,7 +65,7 @@ async function main() { const exitCode = await runConversion(logger, { logFile: LOG_FILE, contentServerUrl: BASE_URL, - entityId: entities[0].id, + entityId, outDirectory: OUT_DIRECTORY, unityPath: $UNITY_PATH, projectPath: $PROJECT_PATH,