Skip to content

Commit

Permalink
Initial migration from GdUnit3 to GdUnit4
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSchulze committed Oct 29, 2022
1 parent 2f181de commit 4456463
Show file tree
Hide file tree
Showing 455 changed files with 35,127 additions and 4 deletions.
21 changes: 21 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Exclude files not needed for AssetLib users.

/.gitattributes export-ignore
/.gitignore export-ignore
/.gitmodules export-ignore
/.github export-ignore
/default_env.tres export-ignore
/icon.png export-ignore
/project.godot export-ignore
/process_example.txt export-ignore
/README.md export-ignore
/gdUnit4.csproj export-ignore
/gdUnit4.sln export-ignore
/CONTRIBUTING.md export-ignore


/addons/gdUnit4/test export-ignore
/gdUnit4-examples export-ignore

# github page assets
/assets export-ignore
13 changes: 13 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
custom: ['https://www.paypal.com/paypalme/GdUnit3']
24 changes: 24 additions & 0 deletions .github/actions/install-godot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: install-godot-image
description: "Installs the Godot image"

inputs:
godot-version:
description: "The Godot Engine version to run"
required: true

runs:
using: composite
steps:
- name: Install Godot ${{ inputs.godot-version }}
id : install
continue-on-error: false
env:
GODOT_BIN: /usr/local/bin/godot/Godot.app/Contents/MacOS/Godot
shell: bash
run: |
mkdir /usr/local/bin/godot
wget https://downloads.tuxfamily.org/godotengine/${{ inputs.godot-version }}/Godot_v${{ inputs.godot-version }}-stable_osx.universal.zip -P /usr/local/bin/godot
unzip /usr/local/bin/godot/Godot_v${{ inputs.godot-version }}-stable_osx.universal.zip -d /usr/local/bin/godot/
rm /usr/local/bin/godot/Godot_v${{ inputs.godot-version }}-stable_osx.universal.zip
ls -lsR /usr/local/bin/godot
chmod 770 /usr/local/bin/godot/Godot.app/Contents/MacOS/Godot
24 changes: 24 additions & 0 deletions .github/actions/publish-test-report/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: publish-test-report
description: "Publishes the GdUnit test results"

inputs:
report-name:
description: "Name of the check run which will be created."
required: true

runs:
using: composite
steps:

- name: 'Fixing the dubious git 128 error'
shell: bash
run: |
git config --global --add safe.directory '*'
- name: 'Publish Test Results'
uses: dorny/[email protected]
with:
name: test_report_${{ inputs.report-name }}
path: 'reports/**/results.xml'
reporter: java-junit
fail-on-error: 'false'
18 changes: 18 additions & 0 deletions .github/actions/unit-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: unit-test
description: "Run unit tests for GdUnit4 API"

inputs:
test-includes:
description: "Paths to include for test run"
required: true
godot-bin:
required: true

runs:
using: composite
steps:
- name: "Unit Test"
env:
GODOT_BIN: ${{ inputs.godot-bin }}
shell: bash
run: ./runtest.sh --add ${{ inputs.test-includes }} --continue
16 changes: 16 additions & 0 deletions .github/actions/upload-test-report/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: upload-test-report
description: "Uploads the GdUnit test reports"

inputs:
report-name:
description: "Name of the report to be upload."
required: true

runs:
using: composite
steps:
- name: Collect Test Artifacts
uses: actions/upload-artifact@v2
with:
name: test_report_${{ inputs.report-name }}
path: reports/**
102 changes: 102 additions & 0 deletions .github/actions/workflow-cleanup/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
const DAYS_TO_EXPIRITION = 5;
const MS_IN_DAYS = 86400000;
const DAYS_TO_EXPIRITION_IN_MS = DAYS_TO_EXPIRITION * MS_IN_DAYS;

module.exports = async ({ github, context, core, exec }) => {
const now = Date.now();
const {
repo: { repo, owner }
} = context;

let activeBranches = [];
await exec.exec('git', ['branch', '-r', '--list'], {
listeners: {
stdout: (data) => {
activeBranches = activeBranches.concat(
data
.toString()
.split('\n')
.map((branch) => branch.replace('origin/', '').trim())
);
}
}
});

core.info(`Found ${activeBranches.length} active branches`);
const filterWorkflowRunsReducer = (
acc,
{ id, head_branch, status, conclusion, created_at, html_url }
) => {
// filter skipped and cancelled workflow runs
if (status === 'completed' && (conclusion === 'skipped' || conclusion === 'cancelled')) {
core.info(
`Add run to delete because of status: "${status}" or conclusion: "${conclusion}". Link: ${html_url}`
);
acc.push(id);
return acc;
}

// filter workflow runs of deleted branches
if (!activeBranches.includes(head_branch)) {
core.info(
`Add run to delete because it is not an active branch: "${head_branch}". Link: ${html_url}`
);
acc.push(id);
return acc;
}

// filter workflow runs older than 5 days
if (now - Date.parse(created_at) > DAYS_TO_EXPIRITION_IN_MS) {
core.info(
`Add run to delete because it is expired: "${created_at}". Link: ${html_url}`
);
acc.push(id);
return acc;
}

core.info(`Will not delete run: ${html_url}`);
return acc;
};

const deleteWorkflowRun = (run_id) => {
core.info(`Attempt to delete workflow run with id: ${run_id}`);

return github.actions.deleteWorkflowRun({
owner,
repo,
run_id
});
};

const pruneWorkflowRuns = async () => {
const workflowRuns = await github.paginate(github.actions.listWorkflowRunsForRepo, {
owner,
repo,
per_page: 100
});

const idsToDelete = workflowRuns.reduce(filterWorkflowRunsReducer, []);

core.info(`Found ${idsToDelete.length} workflow runs that are obsolete`);

core.startGroup('Delete workflow runs');
const responses = await Promise.all(idsToDelete.map(deleteWorkflowRun));
core.endGroup();

return responses;
};

try {
const response = await pruneWorkflowRuns();
const failed = response.filter(({ status }) => status < 200 || status > 300);

core.notice(`Deleted ${response.length - failed.length} obsolete workflow runs`);
core.notice(`${failed.length} deletion(s) failed`);

if (failed.length > 0) {
console.log(failed);
}
} catch (e) {
core.setFailed(`Action failed with error ${e}`);
}
};
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/addons/gdUnit4/" # Location of package manifests
schedule:
interval: "daily"
19 changes: 19 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# release.yml

changelog:
exclude:
labels:
- ignore-for-release

categories:
- title: Improvements
labels:
- enhancement

- title: Bug Fixes
labels:
- bug

- title: Other Changes
labels:
- "*"
92 changes: 92 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: ci-pr

on:
pull_request:
paths-ignore:
- '**.jpg'
- '**.png'
- '**.md'
workflow_dispatch:

env:
GODOT_BIN: "/usr/local/bin/godot"

concurrency:
group: ci-pr-${{ github.event.number }}
cancel-in-progress: true

jobs:

unit-test:
strategy:
fail-fast: false
matrix:
godot-build: ['', 'mono-']
godot-version: [4.0]

name: "CI on Godot ${{ matrix.godot-build }}v${{ matrix.godot-version }}"
runs-on: ubuntu-latest
timeout-minutes: 15
continue-on-error: false
container:
image: barichello/godot-ci:${{ matrix.godot-build }}${{ matrix.godot-version }}

steps:
- name: "Checkout Repository"
uses: actions/checkout@v3
with:
lfs: true
submodules: 'recursive'

- name: "Setup .NET"
if: ${{ startsWith( matrix.godot-build, 'mono') }} # we only setup .Net for mono versions
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x

- name: "Compile C#"
if: ${{ startsWith( matrix.godot-build, 'mono') }} # we only compile .Net for mono versions
run: |
${{ env.GODOT_BIN }} project.godot --build-solutions --quit --no-window
- name: "Update Project"
if: ${{ !cancelled() }}
timeout-minutes: 1
continue-on-error: true # we still ignore the timeout, the script is not quit and we run into a timeout
run: |
${{ env.GODOT_BIN }} -e --path . -s res://addons/gdUnit4/src/core/scan_project.gd --no-window
#- name: "Run example mono Test"
# timeout-minutes: 1
# uses: ./.github/actions/unit-test
# with:
# godot-bin: ${{ env.GODOT_BIN }}
# test-includes: "res://addons/gdUnit4/test/mono"

- name: "Run Unit Test"
if: ${{ !cancelled() }}
timeout-minutes: 10
uses: ./.github/actions/unit-test
with:
godot-bin: ${{ env.GODOT_BIN }}
test-includes: "res://addons/gdUnit4/test/"

- name: "Run Unit Test Examples"
if: ${{ !cancelled() }}
timeout-minutes: 1
uses: ./.github/actions/unit-test
with:
godot-bin: ${{ env.GODOT_BIN }}
test-includes: "res://gdUnit4-examples"

- name: "Publish Unit Test Reports"
if: ${{ !cancelled() }}
uses: ./.github/actions/publish-test-report
with:
report-name: ${{ matrix.godot-build }}${{ matrix.godot-version }}

- name: "Upload Unit Test Reports"
if: ${{ !cancelled() }}
uses: ./.github/actions/upload-test-report
with:
report-name: ${{ matrix.godot-build }}${{ matrix.godot-version }}
24 changes: 24 additions & 0 deletions .github/workflows/deploy-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deploy-GdUnit3-GitHub-Pages

on:
push:
branches:
- documentation
workflow_dispatch:

jobs:
github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: documentation
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile') }}
restore-keys: |
${{ runner.os }}-gems-
- uses: helaili/jekyll-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit 4456463

Please sign in to comment.