-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8b2a92a
Showing
9 changed files
with
440 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
commits: | ||
upstreamBranch: origin/main |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# EditorConfig helps developers define and maintain consistent | ||
# coding styles between different editors and IDEs | ||
# editorconfig.org | ||
|
||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
max_line_length = 120 | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
# double whitespace at end of line | ||
# denotes a line break in Markdown | ||
trim_trailing_whitespace = false | ||
indent_size = unset | ||
max_line_length = 150 | ||
|
||
[{*.yml,*.yaml}] | ||
indent_size = 2 | ||
max_line_length = 150 | ||
|
||
# Ignore paths | ||
[{.git/**/*,**/*.lock,**/Move.toml}] | ||
charset = unset | ||
end_of_line = unset | ||
indent_size = unset | ||
indent_style = unset | ||
insert_final_newline = unset | ||
max_line_length = unset | ||
trim_trailing_whitespace = unset |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Detect Changes | ||
description: Defines variables indicating the parts of the code that changed | ||
outputs: | ||
isMove: | ||
description: True when changes happened to the Move code | ||
value: "${{ steps.diff.outputs.isMove }}" | ||
isRust: | ||
description: True when changes happened to the Rust code | ||
value: "${{ steps.diff.outputs.isRust }}" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Detect Changes | ||
uses: dorny/paths-filter@v2.11.1 | ||
id: diff | ||
with: | ||
filters: | | ||
isMove: | ||
- 'contracts/**' | ||
- '.github/workflows/rust.yml' | ||
isRust: | ||
- 'crates/**' | ||
- 'Cargo.toml' | ||
- 'Cargo.lock' | ||
- '.github/workflows/rust.yml' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Documentation for all configuration options: | ||
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "cargo" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "sunday" | ||
commit-message: | ||
prefix: "fix" | ||
prefix-development: "chore" | ||
include: "scope" | ||
ignore: | ||
- dependency-name: "*" | ||
update-types: ["version-update:semver-patch"] | ||
open-pull-requests-limit: 20 | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
day: "sunday" | ||
commit-message: | ||
prefix: "chore" | ||
include: "scope" | ||
ignore: | ||
- dependency-name: "*" | ||
update-types: ["version-update:semver-patch"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
# Adapted from https://github.com/hrvey/combine-prs-workflow | ||
# SPDX-FileCopyrightText: 2020 Hrvey | ||
# SPDX-License-Identifier: MIT | ||
|
||
name: 'Combine PRs' | ||
|
||
on: | ||
# Combine PRs every Monday morning (after PRs were created on Sunday). | ||
schedule: | ||
- cron: '14 3 * * 1' | ||
# Manual job | ||
workflow_dispatch: | ||
inputs: | ||
branchPrefix: | ||
description: 'Branch prefix to find combinable PRs based on' | ||
required: true | ||
default: 'dependabot' | ||
mustBeGreen: | ||
description: 'Only combine PRs that are green (status is success). Set to false if repo does not run checks' | ||
type: boolean | ||
required: true | ||
default: true | ||
combinedBranchName: | ||
description: 'Name of the branch to combine PRs into' | ||
required: true | ||
default: 'deps/combined-prs' | ||
combinedTitle: | ||
description: 'Title of the combined PR' | ||
required: true | ||
default: 'fix(deps): update non-major dependencies' | ||
ignoreLabel: | ||
description: 'Exclude PRs with this label' | ||
required: true | ||
default: 'major' | ||
combinedLabels: | ||
description: 'Labels to assign (comma-separated list)' | ||
required: true | ||
default: 'dependencies' | ||
|
||
env: | ||
defaultTitle: 'fix(deps): update non-major dependencies' | ||
branchPrefix: ${{ inputs.branchPrefix || 'dependabot' }} | ||
mustBeGreen: ${{ inputs.mustBeGreen || github.event_name == 'schedule' }} | ||
combinedBranchName: ${{ inputs.combinedBranchName || 'deps/combined-prs' }} | ||
ignoreLabel: ${{ inputs.ignoreLabel || 'major' }} | ||
combinedLabels: ${{ inputs.combinedLabels || 'dependencies' }} | ||
|
||
jobs: | ||
combine-prs: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/github-script@v6 | ||
id: create-combined-pr | ||
name: Create Combined PR | ||
with: | ||
github-token: ${{secrets.GITHUB_TOKEN}} | ||
script: | | ||
const pulls = await github.paginate('GET /repos/:owner/:repo/pulls', { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo | ||
}); | ||
let branchesAndPRStrings = []; | ||
let baseBranch = null; | ||
let baseBranchSHA = null; | ||
for (const pull of pulls) { | ||
const branch = pull['head']['ref']; | ||
console.log('Pull for branch: ' + branch); | ||
if (branch.startsWith('${{ env.branchPrefix }}')) { | ||
console.log('Branch matched prefix: ' + branch); | ||
let statusOK = true; | ||
if(${{ env.mustBeGreen }}) { | ||
console.log('Checking green status: ' + branch); | ||
const stateQuery = `query($owner: String!, $repo: String!, $pull_number: Int!) { | ||
repository(owner: $owner, name: $repo) { | ||
pullRequest(number:$pull_number) { | ||
commits(last: 1) { | ||
nodes { | ||
commit { | ||
statusCheckRollup { | ||
state | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
const vars = { | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: pull['number'] | ||
}; | ||
const result = await github.graphql(stateQuery, vars); | ||
const [{ commit }] = result.repository.pullRequest.commits.nodes; | ||
const state = commit.statusCheckRollup.state | ||
console.log('Validating status: ' + state); | ||
if(state != 'SUCCESS') { | ||
console.log('Discarding ' + branch + ' with status ' + state); | ||
statusOK = false; | ||
} | ||
} | ||
console.log('Checking labels: ' + branch); | ||
const labels = pull['labels']; | ||
for(const label of labels) { | ||
const labelName = label['name']; | ||
console.log('Checking label: ' + labelName); | ||
if(labelName == '${{ env.ignoreLabel }}') { | ||
console.log('Discarding ' + branch + ' with label ' + labelName); | ||
statusOK = false; | ||
} | ||
} | ||
if (statusOK) { | ||
console.log('Adding branch to array: ' + branch); | ||
const prString = '#' + pull['number'] + ' ' + pull['title']; | ||
branchesAndPRStrings.push({ branch, prString }); | ||
baseBranch = pull['base']['ref']; | ||
baseBranchSHA = pull['base']['sha']; | ||
} | ||
} | ||
} | ||
if (branchesAndPRStrings.length == 0) { | ||
core.setFailed('No PRs/branches matched criteria'); | ||
return; | ||
} | ||
try { | ||
await github.rest.git.createRef({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
ref: 'refs/heads/' + '${{ env.combinedBranchName }}', | ||
sha: baseBranchSHA | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
core.setFailed('Failed to create combined branch - maybe a branch by that name already exists?'); | ||
return; | ||
} | ||
let combinedPRs = []; | ||
let mergeFailedPRs = []; | ||
for(const { branch, prString } of branchesAndPRStrings) { | ||
try { | ||
await github.rest.repos.merge({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
base: '${{ env.combinedBranchName }}', | ||
head: branch, | ||
}); | ||
console.log('Merged branch ' + branch); | ||
combinedPRs.push(prString); | ||
} catch (error) { | ||
console.log('Failed to merge branch ' + branch); | ||
mergeFailedPRs.push(prString); | ||
} | ||
} | ||
console.log('Creating combined PR'); | ||
const combinedPRsString = combinedPRs.join('\n'); | ||
let body = '✅ This PR was created by the Combine PRs action from the following PRs:\n' + combinedPRsString; | ||
if(mergeFailedPRs.length > 0) { | ||
const mergeFailedPRsString = mergeFailedPRs.join('\n'); | ||
body += '\n\n⚠️ The following PRs were left out due to merge conflicts:\n' + mergeFailedPRsString | ||
} | ||
await github.rest.pulls.create({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
title: '${{ inputs.combinedTitle || env.defaultTitle }}', | ||
head: '${{ env.combinedBranchName }}', | ||
base: baseBranch, | ||
body: body, | ||
labels: '${{ env.combinedLabels }}'.split(",") | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Lint | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
conventional_commit: | ||
runs-on: ubuntu-latest | ||
name: Check conventional commit messages | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Check commit messages | ||
uses: aevea/commitsar@v0.20.1 | ||
- name: Check PR title | ||
uses: amannn/action-semantic-pull-request@v5.2.0 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
editorconfig: | ||
runs-on: ubuntu-latest | ||
name: Check editorconfig | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: editorconfig-checker/action-editorconfig-checker@v1.0.0 | ||
typos: | ||
runs-on: ubuntu-latest | ||
name: Check spelling | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: crate-ci/typos@v1.14.9 |
Oops, something went wrong.