Skip to content

Commit

Permalink
add manual conversion workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
menduz committed Feb 2, 2023
1 parent fe86e68 commit 6a65ca7
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 3 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/manual-build-conversion.yml
Original file line number Diff line number Diff line change
@@ -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/**/*
14 changes: 11 additions & 3 deletions consumer-server/src/test-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')

Expand All @@ -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,
Expand Down

0 comments on commit 6a65ca7

Please sign in to comment.