Skip to content

Commit

Permalink
CLOUDP-213618: Simplify forked Version 2 (#1276)
Browse files Browse the repository at this point in the history
* Simplify forked Version 2 (#1267)

Signed-off-by: Jose Vazquez <jose.vazquez@mongodb.com>

* Apply suggestions from code review

Co-authored-by: Sergiusz Urbaniak <sergiusz.urbaniak@gmail.com>

---------

Signed-off-by: Jose Vazquez <jose.vazquez@mongodb.com>
Co-authored-by: Sergiusz Urbaniak <sergiusz.urbaniak@gmail.com>
  • Loading branch information
josvazg and s-urbaniak committed Dec 15, 2023
1 parent d056efa commit a440b19
Show file tree
Hide file tree
Showing 23 changed files with 167 additions and 249 deletions.
1 change: 1 addition & 0 deletions .github/actions/build-push-image/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ runs:
uses: actions/setup-go@v4
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false
- name: Setup cache
if: ${{ inputs.get-existing-cache == 'false' }}
uses: actions/cache@v3
Expand Down
15 changes: 2 additions & 13 deletions .github/workflows/check-licenses.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,13 @@ name: Check Licenses

on:
workflow_call:
inputs:
forked:
type: boolean
required: false
default: false

jobs:
check-licenses:
name: Check Licenses
runs-on: ubuntu-latest
steps:
- if: ${{ inputs.forked == false }}
uses: actions/checkout@v4

- if: ${{ inputs.forked == true }}
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- uses: actions/checkout@v4

- name: Cache multiple paths
uses: actions/cache@v3
Expand All @@ -34,6 +22,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false

- run: go version

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/cleanup-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/tools/clean/go.mod"
cache: false

- name: Build clean tool
run: (cd tools/clean && go build .)
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/cloud-tests-filter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Cloud Tests Filter

on:
workflow_call:
outputs:
production-code-changed:
description: "Was production code changed?"
value: ${{ jobs.cloud-tests-filter.outputs.production-code-changed }}
run-cloud-tests:
description: "Should cloud tests run?"
value: ${{ jobs.cloud-tests-filter.outputs.run-cloud-tests == 'true' }}

jobs:
cloud-tests-filter:
runs-on: ubuntu-latest
outputs:
production-code-changed: ${{ steps.paths-filter.outputs.production-code-changed }}
run-cloud-tests: ${{ steps.tests-filter.outputs.run-cloud-tests }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: paths-filter
with:
# production code also includes changes to e2e and int tests,
# note any other paths are covered by unit testing which run always
filters: |
production-code-changed:
- 'cmd/**/!(*_test.go)'
- 'pkg/**/!(*_test.go)'
- 'Dockerfile'
- 'test/e2e/**'
- 'test/int/**'
# run only if 'production-code' files were changed
- name: Production code changed
if: steps.paths-filter.outputs.production-code-changed == 'true'
run: echo "Production code was changed"

- name: Tests Filter
id: tests-filter
env:
CLOUD_TESTS_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'cloud-tests') }}
SAFE_TO_TEST_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'safe-to-test') }}
EVENT: ${{ github.event_name }}
ACTION: ${{ github.event.action }}
FORKED: ${{ github.event.repository.full_name != github.event.pull_request.head.repo.full_name }}
DRAFT: ${{ github.event.pull_request.draft }}
CODE_CHANGED: ${{ steps.paths-filter.outputs.production-code-changed }}
GH_REF: ${{ github.ref }}
PR_HEAD_REPONAME: ${{ github.event.pull_request.head.repo.full_name }}
REPONAME: ${{ github.repository }}
ACTOR: ${{ github.actor }}
run: |
# Evaluate whether or not cloud tests should run
RUN_CLOUD_TESTS='false'
# cloud-tests label forces cloud tests to run, BUT only on AKO PRs, not from forked repos
if [ "${CLOUD_TESTS_LABEL}" == "true" ] && [ "${FORKED}" == "false" ];then
RUN_CLOUD_TESTS='true'
# safe-to-test label forces clous tests to run, BUT only when the PR was just "labeled" safe to test
elif [ "${SAFE_TO_TEST_LABEL}" == "true" ] && [ "${ACTION}" == "labeled" ];then
RUN_CLOUD_TESTS='true'
# otherwise run only for regular AKO PRs (not draft nor forked) which include code changes
elif [ "${FORKED}" == "false" ] && [ "${DRAFT}" == "false" ] && [ "${CODE_CHANGED}" == "true" ]; then
RUN_CLOUD_TESTS='true'
fi
echo "run-cloud-tests=${RUN_CLOUD_TESTS}" >> "$GITHUB_OUTPUT"
# run only if not cloud tests should run
- name: Cloud tests should run
if: steps.tests-filter.outputs.run-cloud-tests == 'true'
run: echo "Cloud tests should run"
45 changes: 0 additions & 45 deletions .github/workflows/cloud-tests-forked.yml

This file was deleted.

23 changes: 12 additions & 11 deletions .github/workflows/cloud-tests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: CloudTests

on:
workflow_call:
inputs:
forked:
type: boolean
required: false
default: false
workflow_call:
inputs:
forked:
type: boolean
required: false
default: false

concurrency:
group: cloud-tests-${{ github.ref == 'refs/heads/main' && 'main' || github.actor || github.triggering_actor }}
Expand All @@ -19,7 +19,8 @@ jobs:
if: |
github.event_name == 'workflow_dispatch' ||
github.ref == 'refs/heads/main' ||
(github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')
(github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') ||
contains(github.event.pull_request.labels.*.name, 'safe-to-test')
steps:
- name: allowed message
run: echo "Allowed to run"
Expand Down Expand Up @@ -47,21 +48,21 @@ jobs:
int-tests:
needs: allowed
uses: ./.github/workflows/integration-test.yml
uses: ./.github/workflows/test-int.yml
secrets: inherit
with:
forked: false
forked: ${{ inputs.forked }}

e2e-tests:
needs: allowed
uses: ./.github/workflows/test-e2e.yml
secrets: inherit
with:
forked: false
forked: ${{ inputs.forked }}

openshift-upgrade-test:
needs: allowed
uses: ./.github/workflows/openshift-upgrade-test.yaml
secrets: inherit
with:
forked: false
forked: ${{ inputs.forked }}
32 changes: 0 additions & 32 deletions .github/workflows/integration-test.yml

This file was deleted.

22 changes: 3 additions & 19 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# Check for every push

name: Lint

on:
workflow_call:
inputs:
forked:
type: boolean
required: false
default: false

jobs:
lint:
Expand All @@ -21,20 +15,10 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v3.7.0
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.54

# Optional: working directory, useful for monorepos
# working-directory:

args: --timeout 10m
# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

- name: lint
run: make lint

- name: Run ShellCheck
uses: bewuethr/shellcheck-action@v2
1 change: 1 addition & 0 deletions .github/workflows/openshift-upgrade-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false

- name: Download tools for openshift test
run: |
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/paths-filter.yml

This file was deleted.

1 change: 1 addition & 0 deletions .github/workflows/rebuild-released-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false
- name: Setup cache
uses: actions/cache@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false

- name: Download dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/tools/makejwt/go.mod"
cache: false
- name: Trigger helm post release workflow
if: ${{ env.RELEASE_HELM == 'true' }}
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-e2e-gov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false
- name: Install dependencies
run: |
go install golang.org/x/tools/cmd/goimports@latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: "${{ github.workspace }}/go.mod"
cache: false
- name: Install operator-sdk-v1.22.0
run: |
wget https://github.com/operator-framework/operator-sdk/releases/download/v1.22.0/operator-sdk_linux_amd64 -q
Expand Down
Loading

0 comments on commit a440b19

Please sign in to comment.