Skip to content

Commit 82bc800

Browse files
authored
docs (repo): CI to check PR titles (#1)
# Motivation We would like commits in the main branch to have conventional commits. # Changes - Add a CI check for conventional commits - Add the required action that checks that all required jobs pass - Add the licence # Tests - Changed the title of this PR to a non-conventional commit. CI failed.
1 parent b1d502f commit 82bc800

File tree

3 files changed

+176
-0
lines changed

3 files changed

+176
-0
lines changed
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: 'Needed jobs succeeded'
2+
description: |
3+
Checks that the jobs needed by the current job succeeded.
4+
5+
If one of the needed jobs fails, GitHub will by default skip the
6+
current job and consider a skipped job to be successful. If
7+
instead you wish the current job to fail if any job needed by
8+
the current one fails, you need to:
9+
10+
- set the current job to always run. (use: `if: $ {{ always() }}`)
11+
- check the result of all the needed jobs. (use this action)
12+
inputs:
13+
needs:
14+
description: "JSON describing the needed jobs. (use: `'$ {{ toJson(needs) }}'`)"
15+
required: true
16+
runs:
17+
using: "composite"
18+
steps:
19+
- name: "Check that we have inputs"
20+
shell: bash
21+
run: |
22+
all_jobs="$(echo '${{ inputs.needs }}' | jq 'to_entries[]')"
23+
[[ "$all_jobs" != "" ]] || {
24+
echo "ERROR: No needs found"
25+
exit 1
26+
}
27+
- name: "Check that all jobs in 'needs' are successful"
28+
shell: bash
29+
run: |
30+
unsuccessful_jobs="$(echo '${{ inputs.needs }}' | jq 'to_entries[] | select(.value.result != "success")')"
31+
if [[ "$unsuccessful_jobs" == "" ]]
32+
then echo "Congratulations, you may pass."
33+
else echo "You shall not pass: Some required tests did not succeed:"
34+
echo "$unsuccessful_jobs"
35+
exit 1
36+
fi

.github/workflows/pr.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 'PR'
2+
on:
3+
pull_request:
4+
types:
5+
- opened
6+
- edited
7+
- reopened
8+
- synchronize
9+
- labeled
10+
jobs:
11+
pr:
12+
name: 'PR'
13+
runs-on: ubuntu-latest
14+
env:
15+
TITLE: ${{ github.event.pull_request.title }}
16+
steps:
17+
- name: Conventional commits
18+
run: |
19+
if [[ "$TITLE" =~ ^(feat|fix|chore|build|ci|docs|style|refactor|perf|test)( ?\([-a-zA-Z0-9,]+\))\!?\: ]]; then
20+
echo "PR Title passes"
21+
else
22+
echo "PR Title does not match conventions: $TITLE"
23+
echo " verb(scope): description"
24+
echo "or for a breaking change:"
25+
echo " verb(scope)!: description"
26+
echo "For scope, please use the affected canister name(s), rust crate name(s) or 'ci' for infrastructure changes."
27+
exit 1
28+
fi
29+
pr-pass:
30+
needs: ["pr"]
31+
if: ${{ always() }}
32+
runs-on: ubuntu-20.04
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: ./.github/actions/needs_success
36+
with:
37+
needs: '${{ toJson(needs) }}'

LICENSE

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
INTERNET COMPUTER COMMUNITY SOURCE LICENSE
2+
3+
v1.0
4+
5+
License text copyright © 2021 DFINITY Foundation, All Rights Reserved. “Internet
6+
Computer Community Source License” is a trademark of the DFINITY Foundation.
7+
8+
TERMS AND CONDITIONS
9+
10+
If you use this code (the “software”), you accept this license. If you do not
11+
accept the license, do not use the software.
12+
13+
1. Definitions
14+
15+
The terms “reproduce,” “reproduction,” “derivative works,” and distribution”
16+
have the same meaning here as under U.S. copyright law.
17+
18+
A “contribution” is the original software, or any additions or changes to the
19+
software.
20+
21+
A “contributor” is any person that distributes its contribution under this
22+
license.
23+
24+
“Internet Computer” is the decentralized compute platform originated by the
25+
DFINITY Foundation and stewarded by the Internet Computer Association.
26+
27+
2. Grant of Rights
28+
29+
(A) Copyright Grant - Subject to the terms of this license, including the
30+
license conditions and limitations in Section 3, each contributor grants you a
31+
non-exclusive, worldwide, royalty-free copyright license to reproduce its
32+
contribution, prepare derivative works of its contribution, and distribute its
33+
contribution or any derivative works that you create.
34+
35+
(B) Patent Grant - Subject to the terms of this license, including the license
36+
conditions and limitations in Section 3, each contributor grants you a
37+
non-exclusive, worldwide, royalty-free license under its licensed patents to
38+
make, have made, use, sell, offer for sale, import, and/or otherwise dispose of
39+
its contribution in the software or derivative works of the contribution in the
40+
software.
41+
42+
3. Conditions and Limitations
43+
44+
(A) Platform Limitation - The licenses granted in sections 2(A) and 2(B) extend
45+
only to the software or derivative works that you create that run directly on
46+
the Internet Computer platform.
47+
48+
(B) This license does not grant you rights to use any contributors’ name, logo,
49+
or trademarks.
50+
51+
(C) If you distribute any portion of the software, you must retain all
52+
copyright, patent, trademark, and attribution notices that are present in the
53+
software.
54+
55+
(D) If you distribute any portion of the software in source code form, you may
56+
do so only under this license by including a complete copy of this license with
57+
your distribution. If you distribute any portion of the software in compiled or
58+
object code form, you may only do so under a license that complies with this
59+
license.
60+
61+
(E) If you have modified the Software or created derivative works, and
62+
distribute such modifications or derivative works, you will cause the modified
63+
files to carry prominent notices so that recipients know that they are not
64+
receiving the original software. Such notices must state: (i) that you have
65+
changed the software; and (ii) the date of any changes.
66+
67+
(F) THE SOFTWARE COMES "AS IS", WITH NO WARRANTIES. THIS MEANS THE CONTRIBUTORS
68+
GIVE NO EXPRESS, IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION,
69+
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR ANY
70+
WARRANTY OF TITLE OR NON-INFRINGEMENT. ALSO, YOU MUST PASS THIS DISCLAIMER ON
71+
WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.
72+
73+
(G) DFINITY WILL NOT BE LIABLE FOR ANY DAMAGES RELATED TO THE SOFTWARE OR THIS
74+
LICENSE, INCLUDING DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL
75+
DAMAGES, TO THE MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT
76+
IS BASED ON (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED
77+
INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
78+
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF YOU OR OTHER PARTY HAS BEEN
79+
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ALSO, YOU MUST PASS THIS LIMITATION
80+
OF LIABILITY ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.
81+
82+
(H) If you bring a patent claim against any contributor over patents that you
83+
claim are infringed by the software or a claim against anyone for their use of
84+
the software, your license the software automatically terminates.
85+
86+
(I) Your rights under this license automatically terminates if you breach it in
87+
any way.
88+
89+
(J) Each contributor grants to the Foundation the right to distribute the
90+
contribution of the contributor under a license which is more permissive than
91+
this license. A more permissive license shall be in particular a license with
92+
less restrictions on how the contribution can be reproduced, modified and
93+
distributed than this license. A more permissive license may be in particular
94+
understood as a license that sets asides the platform limitation in section 3
95+
(A) of this license. A more permissive license shall include in particular the
96+
Apache License Version 2.0 (or future versions thereof) and the MIT License. The
97+
decision on such a distribution under a more permissive license is at the sole
98+
discretion of the Foundation
99+
100+
(K) The Foundation reserves all rights not expressly granted to you in this
101+
license.
102+
103+
END OF TERMS AND CONDITIONS

0 commit comments

Comments
 (0)