From 19c686b391e7012699aad4e6c45294decc9bab28 Mon Sep 17 00:00:00 2001 From: veeck Date: Tue, 7 Feb 2023 20:34:34 +0100 Subject: [PATCH 1/3] Add workflow rule to prohibit PRs against master --- .github/workflows/enforce-changelog.yaml | 19 ------------- .../workflows/enforce-pullrequest-rules.yaml | 27 +++++++++++++++++++ CHANGELOG.md | 1 + 3 files changed, 28 insertions(+), 19 deletions(-) delete mode 100644 .github/workflows/enforce-changelog.yaml create mode 100644 .github/workflows/enforce-pullrequest-rules.yaml diff --git a/.github/workflows/enforce-changelog.yaml b/.github/workflows/enforce-changelog.yaml deleted file mode 100644 index 9632ac2d29..0000000000 --- a/.github/workflows/enforce-changelog.yaml +++ /dev/null @@ -1,19 +0,0 @@ -# This workflow enforces the update of a changelog file on every pull request -# For more information see: https://github.com/dangoslen/changelog-enforcer - -name: "Enforce Changelog" - -on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] - -jobs: - check: - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - name: Enforce changelog️ - uses: dangoslen/changelog-enforcer@v3 - with: - changeLogPath: "CHANGELOG.md" - skipLabels: "Skip Changelog" diff --git a/.github/workflows/enforce-pullrequest-rules.yaml b/.github/workflows/enforce-pullrequest-rules.yaml new file mode 100644 index 0000000000..e59819891a --- /dev/null +++ b/.github/workflows/enforce-pullrequest-rules.yaml @@ -0,0 +1,27 @@ +# This workflow enforces on every pull request: +# - the update of our CHANGELOG.md file, see: https://github.com/dangoslen/changelog-enforcer +# - that the PR is not based against master, taken from https://github.com/oppia/oppia-android/pull/2832/files + +name: "Enforce Pull-Request Rules" + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] + +jobs: + check: + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: "Enforce changelog" + uses: dangoslen/changelog-enforcer@v3 + with: + changeLogPath: "CHANGELOG.md" + skipLabels: "Skip Changelog" + - name: "Enforce develop branch" + if: ${{ github.base_ref == 'master' }} + run: | + echo "This PR is based against the master branch. Please don't do this. Switch the branch to 'develop'." + exit 1 + env: + BASE_BRANCH: ${{ github.base_ref }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 67c0ae3be1..bad4aefc82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,6 +65,7 @@ Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not al - Added Yr as a weather provider - Added config options "ignoreXOriginHeader" and "ignoreContentSecurityPolicy" - Added thai language +- Added workflow rule to make sure PRs are based against develop ### Removed From 98e1d68b4bccf6003994b81efc6232d7dd353791 Mon Sep 17 00:00:00 2001 From: veeck Date: Tue, 7 Feb 2023 20:36:05 +0100 Subject: [PATCH 2/3] Cleanup workflows --- .github/workflows/automated-tests.yaml | 6 +++--- .github/workflows/codecov-test-suites.yaml | 6 +++--- .github/workflows/depsreview.yaml | 6 +++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.github/workflows/automated-tests.yaml b/.github/workflows/automated-tests.yaml index 05ce5e455e..28957b000d 100644 --- a/.github/workflows/automated-tests.yaml +++ b/.github/workflows/automated-tests.yaml @@ -20,14 +20,14 @@ jobs: matrix: node-version: [14.x, 16.x, 18.x] steps: - - name: Checkout code + - name: "Checkout code" uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} + - name: "Use Node.js ${{ matrix.node-version }}" uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} cache: "npm" - - name: Install dependencies and run tests + - name: "Install dependencies and run tests" run: | Xvfb :99 -screen 0 1024x768x16 & export DISPLAY=:99 diff --git a/.github/workflows/codecov-test-suites.yaml b/.github/workflows/codecov-test-suites.yaml index b46a4724c8..8cdcccbb7e 100644 --- a/.github/workflows/codecov-test-suites.yaml +++ b/.github/workflows/codecov-test-suites.yaml @@ -17,16 +17,16 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 steps: - - name: Checkout code + - name: "Checkout code" uses: actions/checkout@v3 - - name: Install dependencies and run coverage + - name: "Install dependencies and run coverage" run: | Xvfb :99 -screen 0 1024x768x16 & export DISPLAY=:99 npm ci touch css/custom.css npm run test:coverage - - name: Upload coverage results to codecov + - name: "Upload coverage results to codecov" uses: codecov/codecov-action@v3 with: files: ./coverage/lcov.info diff --git a/.github/workflows/depsreview.yaml b/.github/workflows/depsreview.yaml index e7c5530b36..308f0017d0 100644 --- a/.github/workflows/depsreview.yaml +++ b/.github/workflows/depsreview.yaml @@ -1,4 +1,8 @@ -name: "Dependency Review" +# This workflow scans your pull requests for dependency changes, and will raise an error if any vulnerabilities or invalid licenses are being introduced. +# For more information see: https://github.com/actions/dependency-review-action + +name: "Review Dependencies" + on: [pull_request] permissions: From 9f49a1114ff7a4dd4db3424c874ab41712556315 Mon Sep 17 00:00:00 2001 From: veeck Date: Wed, 8 Feb 2023 21:56:02 +0100 Subject: [PATCH 3/3] Add PR labels conditional --- .github/workflows/enforce-pullrequest-rules.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/enforce-pullrequest-rules.yaml b/.github/workflows/enforce-pullrequest-rules.yaml index e59819891a..22d9c212ea 100644 --- a/.github/workflows/enforce-pullrequest-rules.yaml +++ b/.github/workflows/enforce-pullrequest-rules.yaml @@ -19,9 +19,10 @@ jobs: changeLogPath: "CHANGELOG.md" skipLabels: "Skip Changelog" - name: "Enforce develop branch" - if: ${{ github.base_ref == 'master' }} + if: ${{ github.base_ref == 'master' && !contains(github.event.pull_request.labels.*.name, 'mastermerge') }} run: | - echo "This PR is based against the master branch. Please don't do this. Switch the branch to 'develop'." + echo "This PR is based against the master branch and not a release or hotfix." + echo "Please don't do this. Switch the branch to 'develop'." exit 1 env: BASE_BRANCH: ${{ github.base_ref }}