Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch for CI #2996

Closed
wants to merge 58 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7f38b32
Change Added
Sharpz7 Sep 25, 2023
96519db
Virtual CI check addition
Sharpz7 Sep 26, 2023
ecef7cf
Adding debug
Sharpz7 Oct 13, 2023
bf65641
More debugging
Sharpz7 Oct 13, 2023
341dc13
More testing
Sharpz7 Oct 13, 2023
83800b9
Added Docker Compose Logs
Sharpz7 Oct 13, 2023
a819fb2
Fix
Sharpz7 Oct 13, 2023
52bd0db
More changes
Sharpz7 Oct 13, 2023
1001c7b
Extending Pulsar wait time
Sharpz7 Oct 13, 2023
4cfbd65
Merge branch 'master' into patch-required-checks
Sharpz7 Oct 13, 2023
17846b2
Try this.
Sharpz7 Oct 14, 2023
2917ece
Update test.yml
Sharpz7 Oct 16, 2023
508da8e
Update test.yml
Sharpz7 Oct 16, 2023
b3afffd
Update test.yml
Sharpz7 Oct 16, 2023
a897304
Debug checks
Sharpz7 Oct 16, 2023
ce91066
More debugging
Sharpz7 Oct 16, 2023
32562cd
Added debugg
Sharpz7 Oct 16, 2023
8a7268c
Merge branch 'master' into patch-required-checks
Sharpz7 Oct 16, 2023
7e1be9d
Trying fixes
Sharpz7 Oct 16, 2023
cc1f033
Removed url
Sharpz7 Oct 16, 2023
9069c43
Update ci.go
Sharpz7 Oct 16, 2023
01644af
Removed frequency in location it is not needed
Sharpz7 Oct 17, 2023
7f598bb
Merged jgiannuzzi/disk-space
Sharpz7 Oct 17, 2023
456d782
Trying new cache technique
Sharpz7 Oct 17, 2023
5082276
Bugfix
Sharpz7 Oct 17, 2023
1e6c131
Bugfix
Sharpz7 Oct 17, 2023
497f3d5
More bugfixes
Sharpz7 Oct 17, 2023
2fd8791
Another fix
Sharpz7 Oct 17, 2023
75a9454
Adding other cache changes
Sharpz7 Oct 17, 2023
349118c
Trying new cache
Sharpz7 Oct 17, 2023
414356e
Merge branch 'master' into patch-required-checks
Sharpz7 Oct 17, 2023
68d8992
Merge branch 'master' into patch-required-checks
Sharpz7 Oct 17, 2023
ed27e23
Some cache fixes
Sharpz7 Oct 17, 2023
4a4d536
Merge branch 'master' into patch-required-checks
Sharpz7 Oct 17, 2023
97cf30e
Bugfix
Sharpz7 Oct 17, 2023
512d323
New cache time
Sharpz7 Oct 17, 2023
81d1f4d
Merge https://github.com/armadaproject/armada into patch-required-checks
Sharpz7 Oct 17, 2023
8951815
Changed times
Sharpz7 Oct 17, 2023
6c4dd1e
Pre-Final Commit
Sharpz7 Oct 17, 2023
9db4190
Need to create cache
Sharpz7 Oct 17, 2023
b31cb2e
Commenting Out Cache
Sharpz7 Oct 17, 2023
a37a930
Should let me test
Sharpz7 Oct 18, 2023
ef0230f
Added design doc
Sharpz7 Oct 18, 2023
22bcd9d
A few more changes
Sharpz7 Oct 18, 2023
20d4261
Added a few more changes
Sharpz7 Oct 18, 2023
ad47bf5
Reverted fork only changes
Sharpz7 Oct 18, 2023
ea7c31b
Added CI Doc
Sharpz7 Oct 18, 2023
72a846a
Update build.yml
Sharpz7 Oct 18, 2023
85d3be1
Trying new change
Sharpz7 Oct 20, 2023
9f62931
Merge branch 'master' into patch-required-checks
Sharpz7 Oct 20, 2023
d393304
Added more changes
Sharpz7 Oct 20, 2023
22a9c7d
Merge branch 'patch-required-checks' of https://github.com/Sharpz7/ar…
Sharpz7 Oct 20, 2023
ab7ff8d
Our changes
Sharpz7 Oct 20, 2023
40a7618
Added some docs changes and a change to python
Sharpz7 Oct 20, 2023
d68fc9f
Added airflow fix
Sharpz7 Oct 20, 2023
fd689eb
Added doc change
Sharpz7 Oct 26, 2023
1123a43
Merge branch 'master' into patch-required-checks
Sharpz7 Oct 26, 2023
8a20780
Added debug step
Sharpz7 Oct 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/README.md
@@ -0,0 +1,3 @@
# CI Documentation

Please see [here](../docs/design/ci/oct-2023.md)
26 changes: 19 additions & 7 deletions .github/workflows/airflow-operator.yml
Expand Up @@ -90,15 +90,27 @@ jobs:
- uses: actions/checkout@v3.3.0
- run: docker buildx create --name ${DOCKER_BUILDX_BUILDER} --driver docker-container --use
- run: docker buildx install
- uses: actions/setup-go@v4

- name: Set up Go
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the test, lint, and release workflows, we use the magnetikonline/action-galng-cache plugin, which functionally replaces the functionality of actions/setup-go and actions/cache/restore together - can that work here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - Now that I deleted the extra folder we cache, this can potentially change. But I do think having separate save and cache steps (Which is not possible with magnetikonline/action-galng-cache) is better?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the advantage of "separate save and cache steps" with using actions/cache/restore - I believe the magnetikonline cache plugin automatically sets up the build and module cache paths as needed before, and persists those when the job is done.

uses: actions/setup-go@v4
with:
go-version: "1.20"
cache: false

# Check for cache
- name: Cache Go modules
uses: actions/cache/restore@v3
with:
go-version: ${{ matrix.go }}
path: |
/home/runner/.cache/go-build
/home/runner/go/pkg/mod
key: ${{ runner.os }}-gocache-${{ hashFiles('**/go.sum','**/tools.yaml') }}
restore-keys: |
${{ runner.os }}-gocache-

- name: Setup and integration tests
run: |
# Manually create folders to ensure perms are correct.
mkdir -p .kube/internal
mkdir -p .kube/external
go run github.com/magefile/mage@v1.14.0 -v localdev minimal
run: go run github.com/magefile/mage@v1.14.0 -v localdev minimal

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/build.yml
Expand Up @@ -16,12 +16,22 @@ jobs:
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false

- name: Cache GOBIN
uses: actions/cache@v3
- name: Free some disk space
run: docker image prune -af

# Check for cache
- name: Cache Go modules
uses: actions/cache/restore@v3
with:
path: /home/runner/go/bin
key: ${{ runner.os }}-gobin-${{ hashFiles('**/tools.yaml') }}
path: |
/home/runner/.cache/go-build
/home/runner/go/pkg/mod

key: ${{ runner.os }}-gocache-${{ hashFiles('**/go.sum','**/tools.yaml') }}
restore-keys: |
${{ runner.os }}-gocache-

- name: Set up Docker Buildx
id: buildx
Expand Down
97 changes: 97 additions & 0 deletions .github/workflows/check-required.yml
@@ -0,0 +1,97 @@
name: Check required jobs

# This workflow is triggered when a workflow run for the CI is completed.
# It checks if the "All required checks done" job was actually successful
# (and not just skipped) and creates a check run if that is the case. The
# check run can be used to protect the main branch from being merged if the
# CI is not passing. We need to use a GitHub app token to create the check
# run because otherwise the check suite will be assigned to the first workflow
# run for the CI, which might not be the latest one. See
# https://github.com/orgs/community/discussions/24616#discussioncomment-6088422
# for more details.

on:
workflow_run:
workflows: [CI]

permissions:
actions: read
checks: write

jobs:
required-jobs:
name: Check required jobs
if: ${{ !github.event.repository.fork }}
environment: create-check
runs-on: ubuntu-latest
steps:
- name: Generate an app token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}

- uses: actions/github-script@v6
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
const ghaAppId = 15368;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this value be a secret? Also, const names are not concise. Would be good to rename to something more descriptive (ghaAppId, ghaName ,myAppId, myName)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. and since we use this check in other repos, I think we should keep it consistent between them in terms of naming

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jgiannuzzi do you know more about how to pick this ID?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh this is the public app ID of GitHub Actions 😄

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. and since we use this check in other repos, I think we should keep it consistent between them in terms of naming

If this is the case, then the best thing would be for this workflow to exist in a dedicated "reusable" repo, and then called (if such a thing is acceptable for Armada). What happens when we have 10 repos all having the same check-required.yml workflow, and something changes in one of them? Are we going to track down the 9 other repos that don't have the latest change and create a PR?

@jgiannuzzi @Sharpz7 feel free to tell me i'm nitpicking

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a great point @pavlovic-ivan

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you agree, i think we should create an action out of this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! You may want to first prototype it in some repo and have your forks of armada and fml use it. If it works well, we can probably create a GR/actions repo to collect all of our shared actions/pipelines, starting with this one.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are reading my mind (with GR/actions)!

const ghaName = 'All required checks done';
const myAppId = ${{ secrets.APP_ID }};
const myName = 'All required checks succeeded';
const owner = context.payload.repository.owner.login;
const repo = context.payload.repository.name;
const sha = context.payload.workflow_run.head_sha;

core.info(`List GitHub Actions check runs for ${sha}.`)
const { data: { check_runs: ghaChecks } } = await github.rest.checks.listForRef({
owner: owner,
repo: repo,
ref: sha,
app_id: ghaAppId,
check_name: ghaName,
});

var newCheck = {
owner: owner,
repo: repo,
name: myName,
head_sha: sha,
status: 'in_progress',
started_at: context.payload.workflow_run.created_at,
output: {
title: 'Not all required checks succeeded',
},
};

core.summary.addHeading('The following required checks have been considered:', 3);
ghaChecks.forEach(check => {
core.summary
.addLink(check.name, check.html_url)
.addCodeBlock(JSON.stringify(check, ['status', 'conclusion', 'started_at', 'completed_at'], 2), 'json');

if (check.status === 'completed' && check.conclusion === 'success') {
newCheck.status = 'completed';
newCheck.conclusion = 'success';
newCheck.started_at = check.started_at;
newCheck.completed_at = check.completed_at;
newCheck.output.title = 'All required checks succeeded';
} else if (check.started_at > newCheck.started_at) {
newCheck.started_at = check.started_at;
}
});
if (ghaChecks.length === 0) {
core.summary.addRaw(`No check runs for ${sha} found.`);
}
newCheck.output.summary = core.summary.stringify();
await core.summary.write();

core.info(`Create own check run for ${sha}: ${JSON.stringify(newCheck, null, 2)}.`)
const { data: { html_url } } = await github.rest.checks.create(newCheck);

await core.summary
.addHeading('Check run created:', 3)
.addLink(myName, html_url)
.addCodeBlock(JSON.stringify(newCheck, null, 2), 'json')
.write();
16 changes: 5 additions & 11 deletions .github/workflows/ci.yml
Expand Up @@ -35,23 +35,17 @@ jobs:
build:
if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
uses: ./.github/workflows/build.yml


# Virtual job that can be configured as a required check before a PR can be merged.
# As GitHub considers a check as successful if it is skipped, we need to check its status in
# another workflow (check-required.yml) and create a check there.
all-required-checks-done:
name: All required checks done
if: github.event_name == 'schedule' || github.event_name == 'push' || github.event.pull_request.head.repo.id != github.event.pull_request.base.repo.id
needs:
- lint
- test
- build
runs-on: ubuntu-22.04
steps:
- uses: actions/github-script@v6
with:
script: |
const results = ${{ toJSON(needs.*.result) }};
if (results.every(res => res === 'success')) {
core.info('All required checks succeeded');
} else {
core.setFailed('Some required checks failed');
}

- run: echo "All required checks done"
24 changes: 18 additions & 6 deletions .github/workflows/lint.yml
Expand Up @@ -29,7 +29,7 @@ jobs:
yarn install --frozen-lockfile && yarn run fmt || true
exit $(git status -s -uno | wc -l)
working-directory: ./internal/lookout/ui
continue-on-error: true
continue-on-error: true

- name: Generating TypeScript lint results as summary
working-directory: ./internal/lookout/ui
Expand All @@ -42,8 +42,8 @@ jobs:
echo -e "### List of Lint Issues \n" >> $GITHUB_STEP_SUMMARY
echo -e "${lint_results}" >> $GITHUB_STEP_SUMMARY
else
echo -e "### No Lint issues found.\n" >> $GITHUB_STEP_SUMMARY
fi
echo -e "### No Lint issues found.\n" >> $GITHUB_STEP_SUMMARY
fi
continue-on-error: true

go-lint:
Expand All @@ -53,10 +53,22 @@ jobs:
- name: Checkout
uses: actions/checkout@v3.3.0

- name: Setup Golang with Cache
uses: magnetikonline/action-golang-cache@v4
- name: Set up Go with Cache
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false

# Check for cache
- name: Cache Go modules
uses: actions/cache/restore@v3
with:
go-version: "1.20"
path: |
/home/runner/.cache/go-build
/home/runner/go/pkg/mod
key: ${{ runner.os }}-gocache-${{ hashFiles('**/go.sum','**/tools.yaml') }}
restore-keys: |
${{ runner.os }}-gocache-

- name: Lint using golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
25 changes: 18 additions & 7 deletions .github/workflows/python-client.yml
Expand Up @@ -73,15 +73,26 @@ jobs:
- uses: actions/checkout@v3.3.0
- run: docker buildx create --name ${DOCKER_BUILDX_BUILDER} --driver docker-container --use
- run: docker buildx install
- uses: actions/setup-go@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
go-version: "1.20"
cache: false

# Check for cache
- name: Cache Go modules
uses: actions/cache/restore@v3
with:
path: |
/home/runner/.cache/go-build
/home/runner/go/pkg/mod
key: ${{ runner.os }}-gocache-${{ hashFiles('**/go.sum','**/tools.yaml') }}
restore-keys: |
${{ runner.os }}-gocache-

- name: Setup and integration tests
run: |
# Manually create folders to ensure perms are correct.
mkdir -p .kube/internal
mkdir -p .kube/external
go run github.com/magefile/mage@v1.14.0 -v localdev minimal
run: go run github.com/magefile/mage@v1.14.0 -v localdev minimal

- name: Install Protoc
uses: arduino/setup-protoc@v2
with:
Expand Down
19 changes: 16 additions & 3 deletions .github/workflows/release.yml
Expand Up @@ -54,10 +54,23 @@ jobs:
- name: Fetch Git tags
run: git fetch --force --tags

- name: Setup Golang with Cache
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here we have the inverse - does magnetikonline/action-golang-cache not work, is buggy, or...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above comment

uses: magnetikonline/action-golang-cache@v4
- name: Set up Go with Cache
uses: actions/setup-go@v4
with:
go-version: "1.20"
go-version: '1.20'
cache: false

# Check for cache
- name: Cache Go modules
uses: actions/cache/restore@v3
with:
path: |
/home/runner/.cache/go-build
/home/runner/go/pkg/mod

key: ${{ runner.os }}-gocache-${{ hashFiles('**/go.sum','**/tools.yaml') }}
restore-keys: |
${{ runner.os }}-gocache-

- name: Set up Docker Buildx
id: buildx
Expand Down