diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcb26f4..ad788b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -89,3 +89,99 @@ jobs: path: | build/th08.dll build/th08.pdb + + compare: + needs: ['build'] + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + - name: Fetch game binary from cache. + uses: actions/cache@v4 + id: cache + with: + path: resources/th08.exe + key: 9f76483c46256804792399296619c1274363c31cd8f1775fafb55106fb852245 + - name: Download original game binary for comparison + if: steps.cache.outputs.cache-hit != 'true' + run: | + curl -L $env:ORIGINAL_URL -o resources/th08.exe + $hash = (Get-FileHash resources/th08.exe).Hash + if ($hash -ne $env:EXPECTED_HASH) { + Write-Host "Downloaded file with unexpected hash." + Write-Host "Expected: " $env:EXPECTED_HASH + Write-Host "Got: $hash" + exit 1 + } + env: + ORIGINAL_URL: ${{ secrets.ORIGINAL_URL }} + EXPECTED_HASH: 330fbdbf58a710829d65277b4f312cfbb38d5448b3df523e79350b879213d924 + + - uses: actions/download-artifact@main + with: + name: th08 + path: build + + - name: Install reccmp + run: pip install reccmp + - name: Setup reccmp + run: | + reccmp-project detect --search-path resources/ + cd build + reccmp-project detect --what recompiled + - name: Print diff summary + working-directory: build + run: python ../scripts/generate_reccmp_diff.py > $env:GITHUB_STEP_SUMMARY + + - name: Reccmp save + working-directory: build + run: | + reccmp-reccmp --target th08 --json th08.json --silent + + - name: Reccmp diff + env: + RELEASE_URL: https://github.com/GensokyoClub/th08/releases/download/continuous + working-directory: build + run: | + # Download the current master state + curl -fLSs -o saved-th08.json $RELEASE_URL/th08.json + + reccmp-reccmp --target th08 --diff saved-th08.json + - uses: actions/upload-artifact@v4 + with: + name: Accuracy Report + path: | + build/th08.json + + + upload: + name: Upload artifacts + needs: [build, build-dll, compare] + runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/main' && !github.event.repository.fork + steps: + - uses: actions/checkout@v4 + with: + repository: probonopd/uploadtool + + - uses: actions/download-artifact@main + with: + name: th08 + path: build + + - uses: actions/download-artifact@main + with: + name: th08-dll + path: build-dll + + - uses: actions/download-artifact@main + with: + name: Accuracy Report + + - name: Upload Continuous Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + ./upload.sh \ + build-dll/* \ + build/* \ + th08.json diff --git a/.github/workflows/compare.yml b/.github/workflows/compare.yml deleted file mode 100644 index 78166c6..0000000 --- a/.github/workflows/compare.yml +++ /dev/null @@ -1,136 +0,0 @@ -name: Compare reimplementation - -on: - workflow_run: - workflows: [Build binary] - types: [completed] - workflow_dispatch: - inputs: - workflow_id: - required: true - type: number - -env: - EXPECTED_HASH: 330fbdbf58a710829d65277b4f312cfbb38d5448b3df523e79350b879213d924 - -jobs: - compare: - runs-on: windows-latest - - permissions: - statuses: write - - steps: - - name: Report tests check - if: ${{ github.event_name == 'workflow_run' }} - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha: context.payload.workflow_run.head_sha, - state: 'pending', - target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - description: 'Comparison checks', - context: 'comparison-checks', - }) - - uses: actions/checkout@v3 - - name: Fetch game binary from cache. - uses: actions/cache@v4 - id: cache - with: - path: resources/th08.exe - key: 9f76483c46256804792399296619c1274363c31cd8f1775fafb55106fb852245 - - name: Download original game binary for comparison - if: steps.cache.outputs.cache-hit != 'true' - run: | - curl -L $env:ORIGINAL_URL -o resources/th08.exe - $hash = (Get-FileHash resources/th08.exe).Hash - if ($hash -ne $env:EXPECTED_HASH) { - Write-Host "Downloaded file with unexpected hash." - Write-Host "Expected: " $env:EXPECTED_HASH - Write-Host "Got: $hash" - exit 1 - } - env: - ORIGINAL_URL: ${{ secrets.ORIGINAL_URL }} - - name: Download reimplemented game binary for comparison (1/2) - uses: actions/github-script@v6 - with: - script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run ? context.payload.workflow_run.id : context.payload.inputs.workflow_id, - }); - let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "th08" - })[0]; - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/th08.zip`, Buffer.from(download.data)); - - name: Download reimplemented game binary for comparison (2/2) - run: | - mkdir recompiled/ - unzip th08.zip -d recompiled/ - - name: Get information on workflow ID - uses: actions/github-script@v6 - id: workflow_run_info - with: - script: | - // get info from workflow_id - let workflowRunInfo = await github.rest.actions.getWorkflowRun({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run ? context.payload.workflow_run.id : context.payload.inputs.workflow_id, - }) - core.setOutput("head_repository_full_name", workflowRunInfo.data.head_repository.full_name) - core.setOutput("head_sha", workflowRunInfo.data.head_sha) - console.log(workflowRunInfo.data.head_repository.full_name, workflowRunInfo.data.head_sha) - - name: Install reccmp - run: pip install reccmp - - name: Setup reccmp - run: | - reccmp-project detect --search-path resources/ - cd recompiled - reccmp-project detect --what recompiled - - name: Create diff summary - working-directory: recompiled - run: python ../scripts/generate_reccmp_diff.py > $env:GITHUB_STEP_SUMMARY - - name: Report tests check - if: ${{ github.event_name == 'workflow_run' && success() }} - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha: context.payload.workflow_run.head_sha, - state: 'success', - target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - description: 'Comparison checks', - context: 'comparison-checks', - }) - - name: Report tests check - if: ${{ github.event_name == 'workflow_run' && failure() }} - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha: context.payload.workflow_run.head_sha, - state: 'failure', - target_url: `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`, - description: 'Comparison checks', - context: 'comparison-checks', - })