Skip to content

Commit

Permalink
simplify github actions workflows (#2338)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Feb 20, 2023
1 parent 8fe8bc5 commit 3b466d2
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 216 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/build-arm64-image.yaml
Expand Up @@ -14,13 +14,10 @@ on:
- 'docs/**'
- '**.md'

concurrency:
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true

env:
GO_VERSION: '1.20'

jobs:
build:
name: Build arm64
Expand All @@ -34,13 +31,11 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '${{ env.GO_VERSION }}'
go-version-file: go.mod
check-latest: true
id: go

- name: Export Go full version
run: |
echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"
run: echo "GO_FULL_VER=$(go version | awk '{print $3}')" >> "$GITHUB_ENV"

- name: Go Cache
uses: actions/cache@v3
Expand All @@ -49,15 +44,13 @@ jobs:
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-${{ env.GO_FULL_VER }}-arm64-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.GO_FULL_VER }}-arm64-
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-arm64-

- name: Build
run: |
make release-arm || make release-arm
run: make release-arm || make release-arm

- name: Push
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'release') }}
if: github.ref == github.event.repository.default_branch || startsWith(github.ref, 'release-')
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-dpdk-image.yaml
Expand Up @@ -14,7 +14,7 @@ jobs:
make build-dpdk
- name: Push
if: ${{ github.ref == 'refs/heads/master' || contains(github.ref, 'release') }}
if: github.ref == github.event.repository.default_branch || startsWith(github.ref, 'release-')
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/build-kube-ovn-debug.yaml
@@ -1,9 +1,6 @@
name: Build Debug
on: workflow_dispatch

env:
GO_VERSION: '1.20'

jobs:
build-debug:
name: Build Debug
Expand All @@ -13,13 +10,11 @@ jobs:
- uses: docker/setup-buildx-action@v2
- uses: actions/setup-go@v3
with:
go-version: '${{ env.GO_VERSION }}'
go-version-file: go.mod
check-latest: true
id: go

- name: Build
run: |
make image-debug
run: make image-debug

- name: Push
env:
Expand Down
52 changes: 47 additions & 5 deletions .github/workflows/build-windows.yaml
@@ -1,6 +1,8 @@
name: Build Windows

on:
workflow_dispatch:
release:
pull_request:
branches:
- master
Expand All @@ -20,13 +22,52 @@ concurrency:
cancel-in-progress: true

env:
GO_VERSION: '1.20'
GOSEC_VERSION: '2.14.0'

jobs:
filter:
name: Path Filter
runs-on: ubuntu-22.04
outputs:
build-ovs-ovn: ${{ steps.filter.outputs.windows-ovs-ovn }}
build-kube-ovn: ${{ steps.filter.outputs.windows-kube-ovn }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
check-latest: true

- name: Generate path filter
env:
GOOS: windows
run: |
filter=".github/path-filters.yaml"
workflow=$(echo ${{ github.workflow_ref }} | awk -F@ '{print $1}' | sed 's@^${{ github.repository }}/@@')
cat > $filter <<EOF
windows-ovs-ovn:
- $workflow
windows-kube-ovn:
- $workflow
- go.mod
- go.sum
EOF
module=$(grep ^module go.mod | awk '{print $2}')
go list -f '{{ join .Deps "\n" }}' cmd/windows | grep ^$module/ | while read pkg; do
echo "- ${pkg#${module}/}/*" >> $filter
done
- uses: dorny/paths-filter@v2
id: filter
with:
filters: .github/path-filters.yaml

build-ovs-and-ovn:
name: Build OVS and OVN
needs:
- filter
runs-on: windows-2019
if: github.event_name != 'pull_request' || needs.filter.outputs.build-ovs-ovn == 'true'
steps:
- name: Check out PTHREADS4W
run: |
Expand Down Expand Up @@ -127,14 +168,16 @@ jobs:

build-kube-ovn:
name: Build Kube-OVN
needs:
- filter
runs-on: windows-2019
if: github.event_name != 'pull_request' || needs.filter.outputs.build-kube-ovn == 'true'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: '${{ env.GO_VERSION }}'
go-version-file: go.mod
check-latest: true
id: go

- name: Export Go full version
run: |
Expand All @@ -149,8 +192,7 @@ jobs:
~\AppData\Local\go-build
~\go\pkg\mod
key: ${{ runner.os }}-${{ env.GO_FULL_VER }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ env.GO_FULL_VER }}-
restore-keys: ${{ runner.os }}-${{ env.GO_FULL_VER }}-

- name: Install gosec
run: |
Expand Down

0 comments on commit 3b466d2

Please sign in to comment.