Skip to content

replace errors.Errorf by fmt.Errorf #51

replace errors.Errorf by fmt.Errorf

replace errors.Errorf by fmt.Errorf #51

name: "build-test-distribute"
on:
push:
branches: ["master", "release-*"]
tags: ["*"]
pull_request_target:
branches: ["master", "release-*"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
# GitHub actions does not share cache across multiple jobs,
# so we have to operate cache in each job and action file
- uses: actions/cache@v3
with:
path: |
~/.kuma-dev
key: ${{ runner.os }}-devtools-${{ hashFiles('mk/dependencies/deps.lock') }}
restore-keys: |
${{ runner.os }}-devtools
- run: |
make dev/tools
- run: |
make clean
- run: |
make check
- run: |
make build
- run: |
make -j build/distributions
- run: |
make -j images
- run: |
make -j docker/save
- name: Pack artifact
run: |
tar -czf build.tar.gz ./build
- name: Temporarily saving build output
uses: actions/upload-artifact@v3
with:
name: build-output
path: build.tar.gz
retention-days: 1
- name: Prepare for container structure test
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ci/skip-container-structure-test') && !contains(github.event.pull_request.labels.*.name, 'ci/skip-test') }}
run: |
sudo apt-get update; sudo apt-get install -y qemu-user-static binfmt-support
- name: Run container structure test
if: ${{ !contains(github.event.pull_request.labels.*.name, 'ci/skip-container-structure-test') && !contains(github.event.pull_request.labels.*.name, 'ci/skip-test') }}
run: |
make test/container-structure
test:
needs: build
runs-on: ubuntu-latest
if: ${{ ! contains(github.event.pull_request.labels.*.name, 'ci/skip-test') }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: |
~/.kuma-dev
key: ${{ runner.os }}-devtools-${{ hashFiles('mk/dependencies/deps.lock') }}
restore-keys: |
${{ runner.os }}-devtools
- name: Free up disk space for the Runner
run: |
# source: https://github.com/apache/flink/blob/master/tools/azure-pipelines/free_disk_space.sh
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^ghc-8.*' || true
sudo apt-get remove -y '^dotnet-.*' || true
sudo apt-get remove -y '^llvm-.*' || true
sudo apt-get remove -y 'php.*' || true
sudo apt-get remove -y azure-cli google-cloud-sdk hhvm google-chrome-stable firefox powershell mono-devel || true
sudo apt-get autoremove -y
sudo apt-get clean
echo "Removing large directories"
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc
docker system prune --all -f
sudo df -h
- name: Run tests
run: |
make test TEST_REPORTS=1
- name: Save test reports
uses: actions/upload-artifact@v3
with:
name: test-reports
path: build/reports
retention-days: 30
distributions:
needs: test
if: ${{ always() && !failure() && !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: "Check if force push"
run: |
PR_FORCE_PUBLISH="${{ contains(github.event.pull_request.labels.*.name, 'ci/force-publish') }}"
RUN_ON_MASTER="${{ github.ref == 'refs/branch/master' }}"
RUN_ON_RELEASE="${{ startsWith(github.ref, 'refs/branch/release-') }}"
RUN_ON_TAG="${{ startsWith(github.ref, 'refs/tags/') }}"
ALL_CONDITIONS="$PR_FORCE_PUBLISH-$RUN_ON_MASTER-$RUN_ON_RELEASE-$RUN_ON_TAG"
if [[ "$ALL_CONDITIONS" == *"true"* ]]; then
'echo "ALLOW_PUSH=true" >> $GITHUB_ENV'
fi
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- uses: actions/cache@v3
with:
path: |
~/.kuma-dev
key: ${{ runner.os }}-devtools-${{ hashFiles('mk/dependencies/deps.lock') }}
restore-keys: |
${{ runner.os }}-devtools
- uses: actions/download-artifact@v3
with:
name: build-output
- name: Unpack artifact
run: |
tar -xzf build.tar.gz
- name: Inspect created tars
run: |
for i in build/distributions/out/*.tar.gz; do echo $i; tar -tvf $i; done
- name: Publish distributions to Pulp
run: |
make publish/pulp
- name: Load images
run: |
make docker/load
- name: Publish images
run: |-
make docker/login
# ensure we always logout
function on_exit() {
make docker/logout
}
trap on_exit EXIT
make docker/push
make docker/manifest