Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 152 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
ColumnLimit: 0
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: 'EXPOSURE_BEGIN'
MacroBlockEnd: 'EXPOSURE_END|EXPOSURE_CHAINTO'
MaxEmptyLinesToKeep: 4
NamespaceIndentation: None
PointerAlignment: Left
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Cpp17
TabWidth: 4
UseTab: ForContinuationAndIndentation
---
Language: ObjC
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: false
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: false
ColumnLimit: 120
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
FixNamespaceComments: false
IncludeBlocks: Preserve
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: true
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: 'EXPOSURE_BEGIN'
MacroBlockEnd: 'EXPOSURE_END|EXPOSURE_CHAINTO'
MaxEmptyLinesToKeep: 4
NamespaceIndentation: None
ObjCBlockIndentWidth: 4
PointerAlignment: Left
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Never
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: true
SpacesInSquareBrackets: false
Standard: Cpp17
TabWidth: 4
UseTab: ForContinuationAndIndentation
...
28 changes: 28 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 120
tab_width = 4
trim_trailing_whitespace = true

[{*.yaml,*.yml,.clang-format,.clang-tidy,_clang-format}]
# In yaml, a two-space indent is used by default in many of the solutions we integrate with.
# Examples are GitHub Actions and Kubernetes
indent_size = 2

[{*.h,*.hpp,*.hxx,*.c,*.cpp,*.cxx}]
# .clang-format should take precedence, but for editors which do not do that we're adding those settings here, too.
indent_style = tab

[*.red]
# Those are yaml files, but do use a 4 space indent
indent_size = 4

[{*.markdown,*.md}]
# In markdown a [double whitespace at the end of a line acts as a line break](https://www.markdownguide.org/basic-syntax/#line-breaks).
# Even though it's controversial to use it for that purpose (there are alternatives like using the `<br />` html tag),
# let's not break it accidentally in files that already use the double whitespace.
trim_trailing_whitespace = false
181 changes: 181 additions & 0 deletions .github/workflows/sync_prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
name: PR Target Sync

on:
push:
branches:
- '*'
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
list-prs:
runs-on: ubuntu-latest
outputs:
pr_list: ${{ steps.list_prs.outputs.pr_list }}
steps:
- name: List Open PRs
id: list_prs
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PLATFORM_SYNC_COMPONENT_FORKS_TOKEN }}
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
});
const prList = pullRequests.map(pr => ({
number: pr.number,
headRef: pr.head.ref,
baseRef: pr.base.ref,
headRepo: pr.head.repo.full_name,
baseRepo: pr.base.repo.full_name,
}));
console.log(`PR List: ${JSON.stringify(prList)}`);
core.setOutput('pr_list', JSON.stringify(prList));

process-prs:
needs: list-prs
runs-on: ubuntu-latest
outputs:
forks: ${{ steps.filter_prs.outputs.forks }}
same_repo: ${{ steps.filter_prs.outputs.same_repo }}
steps:
- name: Filter PRs Targeting the Updated Branch
id: filter_prs
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PLATFORM_SYNC_COMPONENT_FORKS_TOKEN }}
script: |
const branchUpdated = context.payload.ref.replace('refs/heads/', '');
const rawPrList = `${{ needs.list-prs.outputs.pr_list }}`;

console.log(`Raw PR List: ${rawPrList}`);

let pullRequests;

try {
pullRequests = JSON.parse(rawPrList);
console.log(`Parsed PR List: ${JSON.stringify(pullRequests)}`);
} catch (error) {
console.error('Error parsing PR list:', error);
pullRequests = [];
}

if (pullRequests.length === 0) {
console.log('No PRs found in the list.');
core.setOutput('forks', '[]');
core.setOutput('same_repo', '[]');
return;
}

const prsToProcess = pullRequests.filter(pr => pr.baseRef === branchUpdated);

console.log(`PRs targeting branch ${branchUpdated}: ${JSON.stringify(prsToProcess)}`);

if (prsToProcess.length === 0) {
console.log(`No PRs found targeting the branch: ${branchUpdated}`);
core.setOutput('forks', '[]');
core.setOutput('same_repo', '[]');
return;
}

const forks = [];
const sameRepo = [];

for (const pr of prsToProcess) {
if (pr.headRepo === `${context.repo.owner}/${context.repo.repo}`) {
sameRepo.push(pr);
} else {
forks.push(pr);
}
}

console.log(`Fork PRs: ${JSON.stringify(forks)}`);
console.log(`Same-repo PRs: ${JSON.stringify(sameRepo)}`);

core.setOutput('forks', JSON.stringify(forks));
core.setOutput('same_repo', JSON.stringify(sameRepo));


sync-forks:
needs: process-prs
if: needs.process-prs.outputs.forks != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pr: ${{ fromJson(needs.process-prs.outputs.forks || '[]') }}
steps:
- name: Checkout Fork Repository
uses: actions/checkout@v4
with:
repository: ${{ matrix.pr.headRepo }}
ref: ${{ matrix.pr.headRef }}
fetch-depth: 0
token: ${{ secrets.PLATFORM_SYNC_COMPONENT_FORKS_TOKEN }}

- name: Add Upstream Remote and Fetch All Branches
run: |
git remote add upstream https://x-access-token:${{ secrets.PLATFORM_SYNC_COMPONENT_FORKS_TOKEN }}@github.com/${{ matrix.pr.baseRepo }}.git
git fetch --all --prune

- name: Configure Committer Identity
run: |
git config --global user.email "teamcoreexternal@ccpgames.com"
git config --global user.name "Platform Automation"

- name: Merge Parent Branch into Fork Branch
run: |
echo "Merging base branch '${{ matrix.pr.baseRef }}' into fork branch '${{ matrix.pr.headRef }}'."
git checkout ${{ matrix.pr.headRef }}
git merge upstream/${{ matrix.pr.baseRef }} --no-edit
git push origin ${{ matrix.pr.headRef }}

- name: Log Merge Result
run: |
echo "Successfully merged '${{ matrix.pr.baseRef }}' from upstream into '${{ matrix.pr.headRef }}' in fork '${{ matrix.pr.headRepo }}'."


sync-same-repo:
needs: process-prs
if: needs.process-prs.outputs.same_repo != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
pr: ${{ fromJson(needs.process-prs.outputs.same_repo || '[]') }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch All Remote Branches
run: |
git fetch --all --prune

- name: Configure Committer Identity
run: |
git config --global user.email "teamcoreexternal@ccpgames.com"
git config --global user.name "Platform Automation"

- name: Merge Parent Branch into Child Branch
run: |
echo "Merging parent branch '${{ matrix.pr.baseRef }}' into child branch '${{ matrix.pr.headRef }}'."
git checkout ${{ matrix.pr.headRef }}
git merge origin/${{ matrix.pr.baseRef }} --no-edit
git push origin ${{ matrix.pr.headRef }}

- name: Log Merge Result
run: |
echo "Successfully merged '${{ matrix.pr.baseRef }}' into '${{ matrix.pr.headRef }}'."






Loading
Loading