Improve ConfirmDialog and automatically handle managed UI objects #1737
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and build SEE | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize, ready_for_review, closed] | |
branches: [master] | |
workflow_dispatch: | |
inputs: | |
windows: | |
description: "Create Windows build?" | |
default: true | |
type: boolean | |
linux: | |
description: "Create Linux build?" | |
default: true | |
type: boolean | |
concurrency: | |
group: ${{ github.ref }} | |
cancel-in-progress: true | |
permissions: read-all | |
jobs: | |
setup: | |
name: Setup Repository | |
# The following condition filters out pull requests that are closed, but not merged. | |
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.state != 'closed' || github.event.pull_request.merged }} | |
runs-on: [self-hosted, see-ci] | |
outputs: | |
runner: ${{ steps.remember.outputs.runner }} | |
steps: | |
- name: Fix permissions | |
shell: bash | |
run: sudo /mnt/scripts/set-work-permissions.sh | |
- name: Setup GitLab LFS | |
run: | | |
echo "$CREDENTIALS" > ~/.git-credentials | |
git config --global credential.helper store | |
git config --global lfs.url "${CREDENTIALS}project-see/see-lfs.git/info/lfs" | |
env: | |
# NOTE: must be of the form https://koschke:token-here@gitlab.informatik.uni-bremen.de/ | |
CREDENTIALS: ${{secrets.GITLAB_LFS_TOKEN}} | |
- uses: actions/checkout@v4 | |
name: Checkout Repository | |
with: | |
lfs: true | |
fetch-depth: 0 | |
- name: Confirm LFS pull | |
run: git lfs pull | |
- name: Remember runner | |
id: remember | |
# We remember this to make sure all jobs are run on the same machine. | |
run: echo "runner=${{ runner.name }}" >> $GITHUB_OUTPUT | |
gitscripts: | |
name: Run GitScript checks | |
runs-on: ${{ needs.setup.outputs.runner }} | |
needs: [setup] | |
if: ${{ github.event_name != 'workflow_dispatch' }} | |
steps: | |
- name: Run GitScripts checks | |
run: ./GitScripts/run_all | |
static: | |
name: Run static checks | |
runs-on: [self-hosted, see-ci] | |
if: ${{ !github.event.pull_request.draft && github.event_name != 'workflow_dispatch' && !github.event.pull_request.merged }} | |
permissions: | |
contents: read | |
issues: read | |
pull-requests: write | |
steps: | |
- name: Collect bad patterns | |
run: | | |
if [ -n "$GITHUB_BASE_REF" ]; then | |
PATTERNS=$(curl -H 'Accept: application/vnd.github.v3.diff' -H 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' -f 'https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.number }}' | ./GitScripts/check_for_bad_patterns.py || true) | |
if [ "$PATTERNS" != "[]" ]; then | |
DELIMITER=7MApgggGyx6C0 | |
echo "PATTERNS<<$DELIMITER" >> $GITHUB_ENV | |
echo "$PATTERNS" >> $GITHUB_ENV | |
echo "$DELIMITER" >> $GITHUB_ENV | |
exit 0 | |
fi | |
fi | |
echo "PATTERNS=none" >> $GITHUB_ENV | |
- uses: actions/github-script@v7 | |
name: Check for bad patterns | |
with: | |
retries: 3 | |
script: | | |
const PATTERNS = process.env.PATTERNS; | |
const helper = require('./GitScripts/review_helper.js'); | |
if (PATTERNS === "none") { | |
console.log("Found no bad patterns in changed files."); | |
} else { | |
let comments = JSON.parse(PATTERNS); | |
console.log("::warning::Found " + comments.length + " bad patterns!"); | |
if (context.ref === 'refs/heads/master') { | |
console.log("However, we are on master, so we ignore them."); | |
} else { | |
await helper.filter_out_existing_comments(github, context, comments); | |
if (comments.length > 0) { | |
console.log("Submitting PR review..."); | |
let limitMessage = ''; | |
if (comments.length > 50) { | |
limitMessage = `\n\n**NOTE: Only the first 50 (out of ${comments.length}) review comments are included.** `; | |
limitMessage += 'Remaining comments will appear when the CI is triggered next.'; | |
comments.splice(50); | |
} | |
try { | |
github.rest.pulls.createReview({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.issue.number, | |
event: 'COMMENT', | |
body: 'There are a few bad patterns I found which you should check.' + limitMessage, | |
comments: comments | |
}); | |
} catch (error) { | |
console.error("Could not submit review for pull request. Please check the error message and, below it, the comments for this PR.\n" + error); | |
console.log("Original comments:"); | |
for (let comment of comments) { | |
console.warn(`${comment['path']}, line ${comment['line']}: ${comment['body']}`); | |
} | |
} | |
} else { | |
console.log("After filtering, no new comments are left. Not submitting a review."); | |
} | |
} | |
} | |
test: | |
name: Run editmode tests | |
runs-on: ${{ needs.setup.outputs.runner }} | |
needs: [setup, gitscripts] | |
if: ${{ ! github.event.pull_request.draft && github.event_name != 'workflow_dispatch' }} | |
permissions: write-all | |
steps: | |
- uses: actions/cache@v4 | |
name: Cache Library | |
env: | |
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 11 | |
with: | |
path: ./Library | |
key: Library-SEE-Tests-${{ hashFiles('./ProjectSettings/ProjectVersion.txt') }} | |
restore-keys: | | |
Library-SEE-Tests | |
Library-SEE | |
- name: Restore NuGet packages | |
run: /home/see/.dotnet/tools/nugetforunity restore . | |
- uses: game-ci/unity-test-runner@v4 | |
timeout-minutes: 60 | |
name: Run Tests | |
id: tests | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
githubToken: ${{ secrets.GITHUB_TOKEN }} | |
checkName: Test Results | |
testMode: EditMode # PlayMode tests get stuck in batchmode | |
runAsHostUser: true | |
customParameters: -testCategory "!NonDeterministic" | |
coverageOptions: "generateAdditionalMetrics;generateHtmlReport;assemblyFilters:+SEE" | |
- uses: actions/upload-artifact@v4 | |
continue-on-error: true | |
name: Upload test results | |
if: ${{ !cancelled() }} | |
with: | |
name: Test results | |
path: ${{ steps.tests.outputs.artifactsPath }} | |
- uses: actions/upload-artifact@v4 | |
continue-on-error: true | |
name: Upload coverage results | |
# Coverage results can get quite large, so only upload on merge into master. | |
if: ${{ github.event.pull_request.merged }} | |
with: | |
name: Coverage results | |
path: ${{ steps.tests.outputs.coveragePath }} | |
setup_build_targets: | |
name: Setup build targets | |
if: ${{ ! github.event.pull_request.draft }} | |
runs-on: [self-hosted, see-ci] | |
outputs: | |
targetPlatforms: ${{ steps.rememberPlatforms.outputs.targetPlatforms }} | |
steps: | |
- id: rememberPlatforms | |
name: Choose platforms for which to create builds | |
run: | | |
if ${{ github.event_name != 'workflow_dispatch' }}; then | |
# Include all target platforms. | |
echo 'targetPlatforms=["StandaloneWindows64", "StandaloneLinux64"]' >> $GITHUB_OUTPUT | |
else | |
# Set targetPlatform based on inputs. | |
targetPlatforms=() | |
if ${{ inputs.windows == true }}; then | |
targetPlatforms+=("StandaloneWindows64") | |
fi | |
if ${{ inputs.linux == true }}; then | |
targetPlatforms+=("StandaloneLinux64") | |
fi | |
echo "targetPlatforms=$(jq --compact-output --null-input '$ARGS.positional' --args -- ${targetPlatforms[@]})" >> $GITHUB_OUTPUT | |
fi | |
build: | |
name: Create build | |
runs-on: ${{ needs.setup.outputs.runner }} | |
needs: [setup, setup_build_targets, test, gitscripts] | |
strategy: | |
matrix: | |
targetPlatform: ${{ fromJson(needs.setup_build_targets.outputs.targetPlatforms) }} | |
if: ${{ ! github.event.pull_request.draft }} | |
steps: | |
- name: Cleanup any modifications | |
run: | | |
sudo /mnt/scripts/set-work-permissions.sh # Permissions may be messed up here | |
git reset --hard ${{ github.sha }} # Test or previous build may have changed files | |
# Try deleting any previous build, but not other zip files that we may need later. | |
git clean -fd -e 'build-*.zip' | |
rm -rf build "build-${{ matrix.targetPlatform }}.zip" || true | |
- name: Restore NuGet packages | |
run: /home/see/.dotnet/tools/nugetforunity restore . | |
- uses: game-ci/unity-builder@v4 | |
timeout-minutes: 90 | |
name: Build project | |
id: build | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
targetPlatform: ${{ matrix.targetPlatform }} | |
buildName: ${{ matrix.targetPlatform }} | |
buildMethod: CITools.BuildScript.Build | |
runAsHostUser: true | |
allowDirtyBuild: true | |
- name: Compress build | |
# Compress only if manually triggered or merged into master, otherwise we won't upload. | |
if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.merged }} | |
run: zip -r build-${{ matrix.targetPlatform }}.zip build/${{ matrix.targetPlatform }} | |
- uses: actions/upload-artifact@v4 | |
continue-on-error: true | |
name: Upload build | |
# Upload only if manually triggered, because for master merges we create a release below anyway. | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
with: | |
name: SEE-${{ matrix.targetPlatform }}-${{ github.sha }}.zip | |
path: build-${{ matrix.targetPlatform }}.zip | |
retention-days: 7 # Due to high space usage. | |
release: | |
name: Release | |
runs-on: ${{ needs.setup.outputs.runner }} | |
permissions: write-all | |
needs: [setup, build] | |
# We only want to create a release after merging a PR into master. | |
# Note that we will not create a release if the PR is labelled 'no release'. | |
# This label should be set when a PR does not lead to a noticeable change in the build. | |
if: ${{ github.event.pull_request.merged && !contains(github.event.pull_request.labels.*.name, 'no release') }} | |
steps: | |
- name: Create release tag | |
uses: rickstaa/action-create-tag@v1 | |
with: | |
tag: pr-${{ github.event.pull_request.number }} | |
message: ${{ github.event.pull_request.title }} | |
- name: Publish release | |
uses: softprops/action-gh-release@v2 | |
with: | |
prerelease: true | |
name: ${{ github.event.pull_request.title }} | |
tag_name: pr-${{ github.event.pull_request.number }} | |
fail_on_unmatched_files: true | |
files: | | |
build-*.zip | |
body: | | |
This release incorporates the changes by @${{ github.event.pull_request.user.login }} from pull request #${{ github.event.pull_request.number }}. | |
Builds for Windows and Linux are available below. | |
## Details | |
${{ github.event.pull_request.body }} | |
--- | |
> [See original pull request for details.](${{ github.event.pull_request.html_url }}) | |
cleanup: | |
name: Cleanup | |
runs-on: ${{ needs.setup.outputs.runner }} | |
if: ${{ always() }} | |
needs: [setup, test, build, release] # "test", "build" and "release" use docker and sometimes mess up permissions. | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Kill Unity | |
if: always() | |
shell: bash | |
run: ./.github/scripts/stop-docker.sh | |
- name: Fix permissions | |
if: always() | |
shell: bash | |
run: sudo /mnt/scripts/set-work-permissions.sh |