Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit 1d5b683

Browse files
committed
Switch runners to run on different repos
* Add conditions on runners for the right place * Change to run within the external fork * Add event differentiator for the trigger * Run StaticAnalysis, Build on every event in the public repo * Run E2E only on pull_request events
1 parent 36b5ba8 commit 1d5b683

File tree

4 files changed

+167
-59
lines changed

4 files changed

+167
-59
lines changed
Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,58 @@
1-
name: End to end tests
1+
name: E2E workflow reusable workflow
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_call:
5+
inputs:
6+
goVersion:
7+
required: false
8+
type: string
9+
default: 1.17
10+
kindversion:
11+
required: false
12+
type: string
13+
default: v0.11.1
14+
imagehash:
15+
required: false
16+
type: string
17+
default: kindest/node:v1.23.0@sha256:49824ab1727c04e56a21a5d8372a402fcd32ea51ac96a2706a12af38934f81ac
18+
runson:
19+
required: false
20+
type: string
21+
default: 'ubuntu-latest'
22+
cleanup:
23+
required: false
24+
type: string
25+
default: 'false'
426

527
jobs:
6-
end-to-end-test:
7-
runs-on: ubuntu-latest
28+
docker-image-cleanup:
29+
if: ${{ inputs.cleanup == 'true' }}
30+
runs-on: ${{ inputs.runson }}
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v2
34+
- name: Show available space
35+
run: df -h
36+
- name: Remove docker dangling images
37+
run: docker images -f dangling=true && docker image prune -f --filter "until=96h"
38+
- name: Show avaiable space after clean-up
39+
run: df -h
40+
end-to-end-test-reusable:
41+
runs-on: ${{ inputs.runson}}
42+
needs: docker-image-cleanup
43+
if: ${{ always() }}
844
steps:
945
- name: Checkout
1046
uses: actions/checkout@v2
1147
- name: Set up Go version
1248
uses: actions/setup-go@v1
1349
with:
14-
go-version: 1.17
50+
go-version: ${{ inputs.goVersion}}
1551
- name: Get tools for cluster installation
16-
run: ./.github/scripts/e2e_get_tools.sh
52+
run: ./.github/scripts/e2e_get_tools.sh ${{ inputs.kindversion }}
1753
- name: Set up cluster with TAS and custom metrics
1854
run: ./.github/scripts/e2e_setup_cluster.sh
1955
- name: Run end to end tests
2056
run: cd .github/e2e/&& go test -v e2e_test.go
21-
- name: Clean up
57+
- name: Clean up Kind cluster
2258
run: ./.github/scripts/e2e_teardown_cluster.sh && ./.github/scripts/e2e_cleanup.sh
Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,28 @@
11
name: Go build and test
22

33
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
4+
workflow_call:
5+
inputs:
6+
runsOn:
7+
required: false
8+
type: string
9+
default: 'ubuntu-latest'
10+
goVersion:
11+
required: false
12+
type: string
13+
default: 1.17
814

915
jobs:
10-
build:
11-
runs-on: ubuntu-latest
16+
build-test:
17+
runs-on: ${{ inputs.runsOn }}
1218
steps:
1319
- uses: actions/checkout@v2
14-
1520
- name: Set up Go
1621
uses: actions/setup-go@v2
1722
with:
18-
go-version: 1.17
19-
23+
go-version: ${{ inputs.goVersion }}
2024
- name: Build
2125
run: make test
22-
2326
- name: Test
2427
run: make build
2528

26-
build-older-go-version:
27-
runs-on: ubuntu-latest
28-
strategy:
29-
matrix:
30-
go-version: [ 1.17.x]
31-
steps:
32-
- uses: actions/checkout@v2
33-
34-
- name: Set up Go
35-
uses: actions/setup-go@v1
36-
with:
37-
go-version: ${{ matrix.go-version }}
38-
39-
- name: Build
40-
run: make build
41-
42-
- name: Test
43-
run: make test
Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,99 @@
11
name: Static Analysis
22

33
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
8-
4+
workflow_call:
5+
inputs:
6+
runsOn:
7+
required: false
8+
type: string
9+
default: 'ubuntu-latest'
10+
scanDir:
11+
required: false
12+
type: string
13+
default: '.'
14+
ignoreDir:
15+
required: false
16+
type: string
17+
default: ''
18+
workingDir:
19+
required: false
20+
default: '.'
21+
type: string
22+
goVersion:
23+
required: false
24+
type: string
25+
default: 1.17
26+
hadolintVersion:
27+
required: false
28+
type: string
29+
default: v2.8.0
30+
goLangCIVersion:
31+
required: false
32+
type: string
33+
default: v1.42.1
34+
goImportsVersion:
35+
required: false
36+
type: string
37+
default: v0.1.9
938
jobs:
1039
shellcheck:
1140
name: Shellcheck
12-
runs-on: ubuntu-latest
41+
runs-on: ${{ inputs.runsOn }}
1342
steps:
14-
- uses: actions/checkout@v2
15-
- name: Run ShellCheck
16-
uses: ludeeus/action-shellcheck@master
43+
- uses: actions/checkout@v2
44+
- name: Run ShellCheck
45+
uses: ludeeus/action-shellcheck@master
46+
with:
47+
scandir: ${{ inputs.scanDir }}
48+
ignore_paths: ${{ inputs.ignoreDir }}
49+
1750
hadolint:
18-
runs-on: ubuntu-latest
1951
name: Hadolint
52+
runs-on: ${{ inputs.runsOn }}
53+
steps:
54+
- uses: actions/checkout@v2
55+
- run: wget -q https://github.com/hadolint/hadolint/releases/download/${{ inputs.hadolintVersion }}/hadolint-Linux-x86_64 -O hadolint; chmod +x hadolint ; find ${{ inputs.scanDir }} -type f \( -name "Dockerfile*" \) -print0 | xargs -n 1 -0 ./hadolint ;
56+
57+
job-process-input:
58+
name: Process workflow input parameters
59+
runs-on: ${{ inputs.runsOn }}
60+
outputs:
61+
modules: ${{ steps.get-modules.outputs.value }}
2062
steps:
21-
- uses: actions/checkout@v2
22-
- run: wget -q https://github.com/hadolint/hadolint/releases/download/v2.8.0/hadolint-Linux-x86_64 -O hadolint; chmod +x hadolint ; find . -type f \( -name "Dockerfile*" \) -print0 | xargs -n 1 -0 ./hadolint ;
63+
- id: get-modules
64+
run: |
65+
echo ${{ inputs.workingDir }} | echo "::set-output name=value::[\"$(sed -r 's/,/","/g')\"]"
66+
2367
gofmt-imports:
24-
runs-on: ubuntu-latest
25-
name: Go Fmt and Go Import
68+
name: Gofmt & imports
69+
needs: job-process-input
70+
runs-on: ${{ inputs.runsOn }}
71+
strategy:
72+
matrix:
73+
modulename: ${{ fromJson(needs.job-process-input.outputs.modules) }}
2674
steps:
2775
- uses: actions/checkout@v2
2876
- uses: actions/setup-go@v2
2977
with:
30-
go-version: 1.17
31-
- run: go install golang.org/x/tools/cmd/goimports@v0.1.9; test -z $(goimports -l .) && test -z $(gofmt -l .)
78+
go-version: ${{ inputs.goVersion }}
79+
- run: go install golang.org/x/tools/cmd/goimports@${{ inputs.goImportsVersion }}; test -z $(goimports -l ${{ matrix.modulename }}) && test -z $(gofmt -l ${{ matrix.modulename }})
3280

33-
golangci-TAS:
81+
golangci-run:
82+
name: Golang CI
83+
runs-on: ${{ inputs.runsOn }}
3484
strategy:
3585
matrix:
3686
workingdir: [extender, telemetry-aware-scheduling, gpu-aware-scheduling]
37-
name: lint
38-
runs-on: ubuntu-latest
3987
steps:
4088
- uses: actions/checkout@v2
4189
- uses: actions/setup-go@v2
4290
with:
43-
go-version: 1.17
44-
- name: golangci-lint-TAS
91+
go-version: ${{ inputs.goVersion }}
92+
- name: Running golang CI for ${{matrix.workingdir}}
4593
uses: golangci/golangci-lint-action@v2
4694
with:
47-
version: v1.42.1
95+
version: ${{ inputs.goLangCIVersion }}
4896
skip-go-installation: true
4997
working-directory: ${{matrix.workingdir }}
50-
# Additional linting tools can be added here
51-
args: --enable=golint --timeout=5m
98+
# Additional linting tools can be added here
99+
args: --enable=golint --timeout=5m

.github/workflows/workflow.yaml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
pull_request:
7+
branches: [ '**' ]
8+
9+
jobs:
10+
11+
static-analysis:
12+
uses: ./.github/workflows/static-analysis.yaml
13+
if: ( contains(github.repository, '/platform-aware-scheduling') )
14+
15+
static-analysis-local:
16+
uses: ./.github/workflows/static-analysis.yaml
17+
if: ( !contains(github.repository, '/platform-aware-scheduling') && github.event_name == 'push' )
18+
with:
19+
runson: self-hosted
20+
21+
go-build-and-test:
22+
uses: ./.github/workflows/go-build-and-test.yml
23+
if: ( contains(github.repository, '/platform-aware-scheduling') )
24+
25+
go-build-and-test-local:
26+
uses: ./.github/workflows/go-build-and-test.yml
27+
if: ( !contains(github.repository, '/platform-aware-scheduling') && github.event_name == 'push' )
28+
with:
29+
runson: self-hosted
30+
31+
end-to-end-test:
32+
uses: ./.github/workflows/end-to-end-test.yaml
33+
if: ( contains(github.repository, '/platform-aware-scheduling') && github.event_name == 'pull_request' )
34+
35+
end-to-end-test-local:
36+
uses: ./.github/workflows/end-to-end-test.yaml
37+
if: ( !contains(github.repository, '/platform-aware-scheduling') && github.event_name == 'pull_request' )
38+
with:
39+
runson: self-hosted-kind

0 commit comments

Comments
 (0)