diff --git a/.github/workflows/ci_suite.yml b/.github/workflows/ci_suite.yml index 1d5b38ea78b..420cf0c9688 100644 --- a/.github/workflows/ci_suite.yml +++ b/.github/workflows/ci_suite.yml @@ -15,11 +15,11 @@ on: - master jobs: run_linters: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ( !contains(github.event.head_commit.message, '[ci skip]') ) name: Run Linters runs-on: ubuntu-22.04 concurrency: - group: run_linters-${{ github.ref }} + group: run_linters-${{ github.head_ref || github.run_id }} cancel-in-progress: true steps: - uses: actions/checkout@v3 @@ -27,25 +27,33 @@ jobs: uses: actions/cache@v3 with: path: ~/SpacemanDMM - key: ${{ runner.os }}-spacemandmm-${{ secrets.CACHE_PURGE_KEY }} + key: ${{ runner.os }}-spacemandmm - name: Restore Yarn cache uses: actions/cache@v3 with: path: tgui/.yarn/cache - key: ${{ runner.os }}-yarn-${{ secrets.CACHE_PURGE_KEY }}-${{ hashFiles('tgui/yarn.lock') }} + key: ${{ runner.os }}-yarn-${{ hashFiles('tgui/yarn.lock') }} restore-keys: | - ${{ runner.os }}-build-${{ secrets.CACHE_PURGE_KEY }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + ${{ runner.os }}-yarn- + - name: Restore Node cache + uses: actions/cache@v3 + with: + path: ~/.nvm + key: ${{ runner.os }}-node-${{ hashFiles('dependencies.sh') }} + restore-keys: | + ${{ runner.os }}-node- + - name: Restore Bootstrap cache + uses: actions/cache@v3 + with: + path: tools/bootstrap/.cache + key: ${{ runner.os }}-bootstrap-${{ hashFiles('tools/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-bootstrap- - name: Restore Rust cache uses: actions/cache@v3 with: path: ~/.cargo - key: ${{ runner.os }}-rust-${{ secrets.CACHE_PURGE_KEY }} - restore-keys: | - ${{ runner.os }}-build-${{ secrets.CACHE_PURGE_KEY }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + key: ${{ runner.os }}-rust - name: Install Tools run: | pip3 install setuptools @@ -96,12 +104,12 @@ jobs: run: tools/build/build --ci lint tgui-test compile_all_maps: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ( !contains(github.event.head_commit.message, '[ci skip]') ) name: Compile Maps needs: [collect_data] runs-on: ubuntu-20.04 concurrency: - group: compile_all_maps-${{ github.ref }} + group: compile_all_maps-${{ github.head_ref || github.run_id }} cancel-in-progress: true steps: - uses: actions/checkout@v3 @@ -109,7 +117,7 @@ jobs: uses: actions/cache@v3 with: path: ~/BYOND - key: ${{ runner.os }}-byond-${{ secrets.CACHE_PURGE_KEY }} + key: ${{ runner.os }}-byond - name: Compile All Maps run: | bash tools/ci/install_byond.sh @@ -122,7 +130,7 @@ jobs: max-required-client-version: ${{needs.collect_data.outputs.max_required_byond_client}} collect_data: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ( !contains(github.event.head_commit.message, '[ci skip]') ) name: Collect data for other tasks runs-on: ubuntu-20.04 outputs: @@ -130,7 +138,7 @@ jobs: alternate_tests: ${{ steps.alternate_test_finder.outputs.alternate_tests }} max_required_byond_client: ${{ steps.max_required_byond_client.outputs.max_required_byond_client }} concurrency: - group: find_all_maps-${{ github.ref }} + group: find_all_maps-${{ github.head_ref || github.run_id }} cancel-in-progress: true steps: - uses: actions/checkout@v3 @@ -153,7 +161,7 @@ jobs: echo "max_required_byond_client=$(grep -Ev '^[[:blank:]]{0,}#{1,}|^[[:blank:]]{0,}$' .github/max_required_byond_client.txt | tail -n1)" >> $GITHUB_OUTPUT run_all_tests: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ( !contains(github.event.head_commit.message, '[ci skip]') ) name: Integration Tests needs: [collect_data] strategy: @@ -161,7 +169,7 @@ jobs: matrix: map: ${{ fromJSON(needs.collect_data.outputs.maps).paths }} concurrency: - group: run_all_tests-${{ github.ref }}-${{ matrix.map }} + group: run_all_tests-${{ github.head_ref || github.run_id }}-${{ matrix.map }} cancel-in-progress: true uses: ./.github/workflows/run_integration_tests.yml with: @@ -169,7 +177,7 @@ jobs: max_required_byond_client: ${{needs.collect_data.outputs.max_required_byond_client}} run_alternate_tests: - if: "!contains(github.event.head_commit.message, '[ci skip]') && needs.find_all_maps.outputs.alternate_tests != '[]'" + if: ( !contains(github.event.head_commit.message, '[ci skip]') && needs.find_all_maps.outputs.alternate_tests != '[]' ) name: Alternate Tests needs: [collect_data] strategy: @@ -177,7 +185,7 @@ jobs: matrix: setup: ${{ fromJSON(needs.collect_data.outputs.alternate_tests) }} concurrency: - group: run_all_tests-${{ github.ref }}-${{ matrix.setup.major }}.${{ matrix.setup.minor }}-${{ matrix.setup.map }} + group: run_all_tests-${{ github.head_ref || github.run_id }}-${{ matrix.setup.major }}.${{ matrix.setup.minor }}-${{ matrix.setup.map }} cancel-in-progress: true uses: ./.github/workflows/run_integration_tests.yml with: @@ -187,7 +195,7 @@ jobs: max_required_byond_client: ${{needs.collect_data.outputs.max_required_byond_client}} check_alternate_tests: - if: "!contains(github.event.head_commit.message, '[ci skip]') && needs.find_all_maps.outputs.alternate_tests != '[]'" + if: ( !contains(github.event.head_commit.message, '[ci skip]') && needs.find_all_maps.outputs.alternate_tests != '[]' ) name: Check Alternate Tests needs: [run_alternate_tests] runs-on: ubuntu-20.04 @@ -195,7 +203,7 @@ jobs: - run: echo Alternate tests passed. compare_screenshots: - if: "!contains(github.event.head_commit.message, '[ci skip]') && always()" + if: ( !contains(github.event.head_commit.message, '[ci skip]') && (success() || failure()) ) needs: [run_all_tests, run_alternate_tests] name: Compare Screenshot Tests runs-on: ubuntu-20.04 @@ -230,12 +238,12 @@ jobs: path: artifacts/screenshot_comparisons test_windows: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ( !contains(github.event.head_commit.message, '[ci skip]') ) name: Windows Build needs: [collect_data] runs-on: windows-latest concurrency: - group: test_windows-${{ github.ref }} + group: test_windows-${{ github.head_ref || github.run_id }} cancel-in-progress: true steps: - uses: actions/checkout@v3 @@ -243,11 +251,9 @@ jobs: uses: actions/cache@v3 with: path: tgui/.yarn/cache - key: ${{ runner.os }}-yarn-${{ secrets.CACHE_PURGE_KEY }}-${{ hashFiles('tgui/yarn.lock') }} + key: ${{ runner.os }}-yarn-${{ hashFiles('tgui/yarn.lock') }} restore-keys: | - ${{ runner.os }}-build-${{ secrets.CACHE_PURGE_KEY }}- - ${{ runner.os }}-build- - ${{ runner.os }}- + ${{ runner.os }}-yarn- - name: Compile run: pwsh tools/ci/build.ps1 env: diff --git a/.github/workflows/docker_publish.yml b/.github/workflows/docker_publish.yml index 48ef92c17f1..e16b9e2f892 100644 --- a/.github/workflows/docker_publish.yml +++ b/.github/workflows/docker_publish.yml @@ -7,7 +7,7 @@ on: jobs: publish: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ( !contains(github.event.head_commit.message, '[ci skip]') ) runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/generate_documentation.yml b/.github/workflows/generate_documentation.yml index 23ce6b1b5df..3f9d8338908 100644 --- a/.github/workflows/generate_documentation.yml +++ b/.github/workflows/generate_documentation.yml @@ -10,7 +10,7 @@ jobs: generate_documentation: permissions: contents: write # for JamesIves/github-pages-deploy-action to push changes in repo - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ( !contains(github.event.head_commit.message, '[ci skip]') ) runs-on: ubuntu-20.04 concurrency: gen-docs steps: diff --git a/.github/workflows/show_screenshot_test_results.yml b/.github/workflows/show_screenshot_test_results.yml index 61fc397477d..32ea68476d2 100644 --- a/.github/workflows/show_screenshot_test_results.yml +++ b/.github/workflows/show_screenshot_test_results.yml @@ -11,7 +11,7 @@ on: - completed jobs: show_screenshot_test_results: - if: "!contains(github.event.head_commit.message, '[ci skip]')" + if: ( !contains(github.event.head_commit.message, '[ci skip]') && github.event.workflow_run.run_attempt == 1 ) name: Show Screenshot Test Results runs-on: ubuntu-20.04 steps: diff --git a/.github/workflows/tgs_test.yml b/.github/workflows/tgs_test.yml new file mode 100644 index 00000000000..4925019bc6a --- /dev/null +++ b/.github/workflows/tgs_test.yml @@ -0,0 +1,68 @@ +name: TGS Test Suite +on: + push: + branches: + - master + - 'project/**' + - 'gh-readonly-queue/master/**' + - 'gh-readonly-queue/project/**' + paths: + - '.tgs.yml' + - '.github/workflows/tgs_test.yml' + - 'dependencies.sh' + - 'code/__DEFINES/tgs.config.dm' + - 'code/__DEFINES/tgs.dm' + - 'code/game/world.dm' + - 'code/modules/tgs/**' + - 'tools/tgs_scripts/**' + - 'tools/tgs_test/**' + pull_request: + branches: + - master + - 'project/**' + paths: + - '.tgs.yml' + - '.github/workflows/tgs_test.yml' + - 'dependencies.sh' + - 'code/__DEFINES/tgs.config.dm' + - 'code/__DEFINES/tgs.dm' + - 'code/game/world.dm' + - 'code/modules/tgs/**' + - 'tools/tgs_scripts/**' + - 'tools/tgs_test/**' + merge_group: + branches: + - master +env: + TGS_API_PORT: 5000 + PR_NUMBER: ${{ github.event.number }} +jobs: + test_tgs_docker: + if: ( !contains(github.event.head_commit.message, '[ci skip]') ) + name: Test TGS Docker + runs-on: ubuntu-22.04 + concurrency: + group: test_tgs_docker-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + services: + tgs: + image: tgstation/server + env: + Database__DatabaseType: Sqlite + Database__ConnectionString: Data Source=TGS_TGTest.sqlite3;Mode=ReadWriteCreate + General__ConfigVersion: 4.1.0 + General__ApiPort: ${{ env.TGS_API_PORT }} + General__SetupWizardMode: Never + ports: + - 5000:5000 #Can't use env here for some reason + steps: + - name: Setup dotnet + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 7.0.x + + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Test TGS Integration + run: dotnet run -c Release --project tools/tgs_test ${{ github.repository }} /tgs_instances/tgstation ${{ env.TGS_API_PORT }} ${{ github.event.pull_request.head.sha || github.sha }} ${{ secrets.GITHUB_TOKEN }} ${{ env.PR_NUMBER }} diff --git a/.tgs.yml b/.tgs.yml index aa8d52acede..b012bdffe23 100644 --- a/.tgs.yml +++ b/.tgs.yml @@ -1,13 +1,25 @@ +# This file is used by TGS (https://github.com/tgstation/tgstation-server) clients to quickly initialize a server instance for the codebase +# The format isn't documented anywhere but hopefully we never have to change it. If there are questions, contact the TGS maintainer Cyberboss/@Dominion#0444 version: 1 -byond: 514.1588 +# The BYOND version to use (kept in sync with dependencies.sh by the "TGS Test Suite" CI job) +# Must be interpreted as a string, keep quoted +byond: "514.1588" +# Folders to create in "/Configuration/GameStaticFiles/" static_files: + # Config directory should be static - name: config + # This implies the folder should be pre-populated with contents from the repo populate: true + # Data directory must be static - name: data +# String dictionary. The value is the location of the file in the repo to upload to TGS. The key is the name of the file to upload to "/Configuration/EventScripts/" +# This one is for Linux hosted servers linux_scripts: PreCompile.sh: tools/tgs_scripts/PreCompile.sh WatchdogLaunch.sh: tools/tgs_scripts/WatchdogLaunch.sh InstallDeps.sh: tools/tgs_scripts/InstallDeps.sh +# Same as above for Windows hosted servers windows_scripts: PreCompile.bat: tools/tgs_scripts/PreCompile.bat +# The security level the game should be run at security: Trusted diff --git a/tools/tgs_test/Program.cs b/tools/tgs_test/Program.cs index 8d279788847..b8967dbc156 100644 --- a/tools/tgs_test/Program.cs +++ b/tools/tgs_test/Program.cs @@ -1,6 +1,6 @@ // Simple app meant to test tgstation's TGS integration given a fresh TGS install with the default account // -// Args: Repository Owner/Name, TGS instance path, TGS API port, Pushed commit hash (For .tgs.yml access), GitHub Token +// Args: Repository Owner/Name, TGS instance path, TGS API port, Pushed commit hash (For .tgs.yml access), GitHub Token, (OPTIONAL) PR Number using System.Reflection; using System.Text; @@ -16,10 +16,9 @@ Console.WriteLine("Parsing args..."); -const int ExpectedArgs = 5; -if (args.Length != ExpectedArgs) +if (args.Length < 5 || args.Length > 6) { - Console.WriteLine($"Incorrect number of args: {args.Length}. Expected {ExpectedArgs}"); + Console.WriteLine($"Incorrect number of args: {args.Length}. Expected 5-6"); return 1; } @@ -29,6 +28,18 @@ var pushedCommitHash = args[3]; var gitHubToken = args[4]; +int? pullRequest = default; +if(args.Length == 6) +{ + if (!Int32.TryParse(args[5], out int prNumber)) + { + Console.WriteLine($"Invalid repo slug: {repoSlug}"); + return 10; + } + + pullRequest = prNumber; +} + var repoSlugSplits = repoSlug.Split('/', StringSplitOptions.RemoveEmptyEntries); if(repoSlugSplits.Length != 2) { @@ -312,6 +323,25 @@ async Task WaitForJob(JobResponse originalJob, int timeout) if (!await WaitForJob(repoCloneJob.ActiveJob!, 600)) return 7; + if (pullRequest.HasValue) + { + Console.WriteLine($"Applying test merge #{pullRequest}..."); + var testMergeJob = await instanceClient.Repository.Update(new RepositoryUpdateRequest + { + NewTestMerges = new List + { + new TestMergeParameters + { + Comment = "Active Pull Request", + Number = pullRequest.Value, + TargetCommitSha = pushedCommitHash + } + } + }, default); + if (!await WaitForJob(testMergeJob.ActiveJob!, 60)) + return 11; + } + Console.WriteLine("Deploying..."); var deploymentJob = await instanceClient.DreamMaker.Compile(default); if (!await WaitForJob(deploymentJob, 1800))