1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

ci: reusable dco workflow

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2022-09-10 15:07:46 +02:00
parent 5a98363a92
commit 7602edfd06
No known key found for this signature in database
GPG key ID: 3248E46B6BB8C7F7
7 changed files with 79 additions and 25 deletions

48
.github/workflows/.dco.yml vendored Normal file
View file

@ -0,0 +1,48 @@
# reusable workflow
name: .dco
# TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025
on:
workflow_call:
env:
ALPINE_VERSION: 3.16
jobs:
run:
runs-on: ubuntu-20.04
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Dump context
uses: actions/github-script@v6
with:
script: |
console.log(JSON.stringify(context, null, 2));
-
name: Get base ref
id: base-ref
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if (/^refs\/pull\//.test(context.ref) && context.payload?.pull_request?.base?.ref != undefined) {
return context.payload.pull_request.base.ref;
}
return context.ref.replace(/^refs\/heads\//g, '');
-
name: Validate
run: |
docker run --rm \
-v "$(pwd):/workspace" \
-e VALIDATE_REPO \
-e VALIDATE_BRANCH \
alpine:${{ env.ALPINE_VERSION }} sh -c 'apk add --no-cache -q bash git openssh-client && git config --system --add safe.directory /workspace && cd /workspace && hack/validate/dco'
env:
VALIDATE_REPO: ${{ github.server_url }}/${{ github.repository }}.git
VALIDATE_BRANCH: ${{ steps.base-ref.outputs.result }}

View file

@ -1,6 +1,8 @@
# reusable workflow # reusable workflow
name: .windows name: .windows
# TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025
on: on:
workflow_call: workflow_call:
inputs: inputs:

View file

@ -16,8 +16,13 @@ env:
BUNDLES_OUTPUT: ./bundles BUNDLES_OUTPUT: ./bundles
jobs: jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
build: build:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs:
- validate-dco
steps: steps:
- -
name: Checkout name: Checkout

View file

@ -18,8 +18,13 @@ env:
BUNDLES_OUTPUT: ./bundles BUNDLES_OUTPUT: ./bundles
jobs: jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
build: build:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs:
- validate-dco
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -54,6 +59,8 @@ jobs:
cross: cross:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs:
- validate-dco
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:

View file

@ -24,8 +24,13 @@ env:
DOCKER_GRAPHDRIVER: overlay2 DOCKER_GRAPHDRIVER: overlay2
jobs: jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
build-dev: build-dev:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs:
- validate-dco
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -91,23 +96,6 @@ jobs:
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
-
name: Dump context
uses: actions/github-script@v6
with:
script: |
console.log(JSON.stringify(context, null, 2));
-
name: Get base ref
id: base-ref
uses: actions/github-script@v6
with:
result-encoding: string
script: |
if (/^refs\/pull\//.test(context.ref) && context.payload?.pull_request?.base?.ref != undefined) {
return context.payload.pull_request.base.ref;
}
return context.ref.replace(/^refs\/heads\//g, '');
- -
name: Set up runner name: Set up runner
uses: ./.github/actions/setup-runner uses: ./.github/actions/setup-runner
@ -125,15 +113,11 @@ jobs:
name: Validate name: Validate
run: | run: |
make -o build validate-${{ matrix.script }} make -o build validate-${{ matrix.script }}
env:
VALIDATE_REPO: ${{ github.server_url }}/${{ github.repository }}.git
VALIDATE_BRANCH: ${{ steps.base-ref.outputs.result }}
unit: unit:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: needs:
- build-dev - build-dev
- validate
steps: steps:
- -
name: Checkout name: Checkout
@ -183,7 +167,6 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: needs:
- build-dev - build-dev
- validate
steps: steps:
- -
name: Checkout name: Checkout
@ -231,7 +214,6 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: needs:
- build-dev - build-dev
- validate
steps: steps:
- -
name: Checkout name: Checkout
@ -260,7 +242,6 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
needs: needs:
- build-dev - build-dev
- validate
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -343,6 +324,8 @@ jobs:
integration-cli-prepare: integration-cli-prepare:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs:
- validate-dco
outputs: outputs:
matrix: ${{ steps.tests.outputs.matrix }} matrix: ${{ steps.tests.outputs.matrix }}
steps: steps:
@ -377,7 +360,6 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
needs: needs:
- build-dev - build-dev
- validate
- integration-cli-prepare - integration-cli-prepare
strategy: strategy:
fail-fast: false fail-fast: false

View file

@ -10,7 +10,12 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
run: run:
needs:
- validate-dco
uses: ./.github/workflows/.windows.yml uses: ./.github/workflows/.windows.yml
with: with:
os: windows-2019 os: windows-2019

View file

@ -13,7 +13,12 @@ on:
pull_request: pull_request:
jobs: jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
run: run:
needs:
- validate-dco
uses: ./.github/workflows/.windows.yml uses: ./.github/workflows/.windows.yml
with: with:
os: windows-2022 os: windows-2022