Skip to content

Commit

Permalink
[MISSED MIRRORS] Linters, part two (#736)
Browse files Browse the repository at this point in the history
* Split Run Linters step into multiple steps (#78265)

---------

Co-authored-by: Bloop <[email protected]>
Co-authored-by: distributivgesetz <[email protected]>
Co-authored-by: Mothblocks <[email protected]>
Co-authored-by: san7890 <[email protected]>
Co-authored-by: Jordan Dominion <[email protected]>
  • Loading branch information
6 people authored Nov 20, 2023
1 parent 5a39bbf commit 38d5519
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 37 deletions.
64 changes: 35 additions & 29 deletions .github/workflows/ci_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,45 @@ 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
- name: Restore SpacemanDMM cache
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
Expand Down Expand Up @@ -96,20 +104,20 @@ 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
- name: Restore BYOND cache
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
Expand All @@ -122,15 +130,15 @@ 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:
maps: ${{ steps.map_finder.outputs.maps }}
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
Expand All @@ -153,31 +161,31 @@ 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:
fail-fast: false
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:
map: ${{ matrix.map }}
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:
fail-fast: false
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:
Expand All @@ -187,15 +195,15 @@ 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
steps:
- 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
Expand Down Expand Up @@ -230,24 +238,22 @@ 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
- 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: Compile
run: pwsh tools/ci/build.ps1
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/show_screenshot_test_results.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/tgs_test.yml
Original file line number Diff line number Diff line change
@@ -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 }}
14 changes: 13 additions & 1 deletion .tgs.yml
Original file line number Diff line number Diff line change
@@ -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 "<instance_path>/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 "<instance_path>/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
38 changes: 34 additions & 4 deletions tools/tgs_test/Program.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}

Expand All @@ -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)
{
Expand Down Expand Up @@ -312,6 +323,25 @@ async Task<bool> 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<TestMergeParameters>
{
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))
Expand Down

0 comments on commit 38d5519

Please sign in to comment.