Switch to promci

Reuse common actions

Signed-off-by: Julien Pivotto <roidelapluie@o11y.eu>
This commit is contained in:
Julien Pivotto 2022-12-20 09:40:31 +01:00
parent 46fb802791
commit 42509bc106
10 changed files with 15 additions and 327 deletions

View File

@ -1,23 +0,0 @@
name: Build
inputs:
thread:
type: integer
description: Current thread
required: true
default: 3
parallelism:
type: integer
description: Number of builds to do in parallel
default: 3
promu_opts:
type: string
description: Options to pass to promu
runs:
using: composite
steps:
- uses: ./.github/actions/setup_environment
- run: ~/go/bin/promu crossbuild -v --parallelism ${{ inputs.parallelism }} --parallelism-thread ${{ inputs.thread }} ${{ inputs.promu_opts }}
shell: bash
- uses: ./.github/actions/save_artifacts
with:
directory: .build

View File

@ -1,20 +0,0 @@
name: Check proto files
inputs:
version:
type: string
description: Protoc version
default: "3.5.1"
runs:
using: composite
steps:
- run: |
env
set -x
curl -s -L https://github.com/protocolbuffers/protobuf/releases/download/v${{ inputs.version }}/protoc-${{ inputs.version }}-linux-x86_64.zip > /tmp/protoc.zip
unzip -d /tmp /tmp/protoc.zip
chmod +x /tmp/bin/protoc
export PATH=/tmp/bin:$PATH
make proto
shell: bash
- run: git diff --exit-code
shell: bash

View File

@ -1,47 +0,0 @@
name: Publish image
inputs:
registry:
type: string
description: Docker registry
organization:
type: string
description: Organization
login:
type: string
description: Username
password:
type: string
description: Password
dockerfile_path:
description: Path to Dockerfile
type: string
default: ""
dockerbuild_context:
description: Path to Dockerbuild context
type: string
default: ""
container_image_name:
description: Name of the container image
type: string
default: ""
runs:
using: composite
steps:
- if: inputs.dockerfile_path != ''
run: echo "export DOCKERFILE_PATH=${{ inputs.dockerfile_path }}" >> /tmp/tmp-profile
shell: bash
- if: inputs.container_image_name != ''
run: echo "export DOCKER_IMAGE_NAME=${{ inputs.container_image_name }}" >> /tmp/tmp-profile
shell: bash
- if: inputs.dockerbuild_context != ''
run: echo "export DOCKERBUILD_CONTEXT=${{ inputs.dockerbuild_context }}" >> /tmp/tmp-profile
shell: bash
- run: |
touch /tmp/tmp-profile
. /tmp/tmp-profile
make docker DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
docker images
echo ${{ inputs.password }} | docker login -u ${{ inputs.login }} --password-stdin ${{ inputs.registry }}
make docker-publish DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-manifest DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
shell: bash

View File

@ -1,43 +0,0 @@
name: Publish image
inputs:
docker_hub_organization:
type: string
description: DockerHub organization
default: prom
docker_hub_login:
type: string
description: DockerHub username
docker_hub_password:
type: string
description: DockerHub password
quay_io_organization:
type: string
description: Quay.io organization
default: prometheus
quay_io_login:
type: string
description: Quay.io username
quay_io_password:
type: string
description: Quay.io password
runs:
using: composite
steps:
- uses: ./.github/actions/setup_environment
with:
enable_docker_multibuild: true
- uses: ./.github/actions/restore_artifacts
- uses: ./.github/actions/publish_images
if: inputs.docker_hub_organization != '' && inputs.docker_hub_login != ''
with:
registry: docker.io
organization: ${{ inputs.docker_hub_organization }}
login: ${{ inputs.docker_hub_login }}
password: ${{ inputs.docker_hub_password }}
- uses: ./.github/actions/publish_images
if: inputs.quay_io_organization != '' && inputs.quay_io_login != ''
with:
registry: quay.io
organization: ${{ inputs.quay_io_organization }}
login: ${{ inputs.quay_io_login }}
password: ${{ inputs.quay_io_password }}

View File

@ -1,54 +0,0 @@
name: Publish image
inputs:
docker_hub_organization:
type: string
description: DockerHub organization
default: prom
docker_hub_login:
type: string
description: DockerHub username
docker_hub_password:
type: string
description: DockerHub password
quay_io_organization:
type: string
description: Quay.io organization
default: prometheus
quay_io_login:
type: string
description: Quay.io username
quay_io_password:
type: string
description: Quay.io password
github_token:
type: string
description: Github Token
runs:
using: composite
steps:
- uses: ./.github/actions/setup_environment
with:
enable_docker_multibuild: true
- uses: ./.github/actions/restore_artifacts
- run: ~/go/bin/promu crossbuild tarballs
shell: bash
- run: ~/go/bin/promu checksum .tarballs
shell: bash
- run: ~/go/bin/promu release .tarballs
shell: bash
env:
GITHUB_TOKEN: ${{ inputs.github_token }}
- uses: ./.github/actions/publish_release_images
if: inputs.docker_hub_organization != '' && inputs.docker_hub_login != ''
with:
registry: docker.io
organization: ${{ inputs.docker_hub_organization }}
login: ${{ inputs.docker_hub_login }}
password: ${{ inputs.docker_hub_password }}
- uses: ./.github/actions/publish_release_images
if: inputs.quay_io_organization != '' && inputs.quay_io_login != ''
with:
registry: quay.io
organization: ${{ inputs.quay_io_organization }}
login: ${{ inputs.quay_io_login }}
password: ${{ inputs.quay_io_password }}

View File

@ -1,53 +0,0 @@
name: Publish release image
inputs:
registry:
type: string
description: Docker registry
organization:
type: string
description: Organization
login:
type: string
description: Username
password:
type: string
description: Password
dockerfile_path:
description: Path to Dockerfile
type: string
default: ""
dockerbuild_context:
description: Path to Dockerbuild context
type: string
default: ""
container_image_name:
description: Name of the container image
type: string
default: ""
runs:
using: composite
steps:
- if: inputs.dockerfile_path != ''
run: echo "export DOCKERFILE_PATH=${{ inputs.dockerfile_path }}" >> /tmp/tmp-profile
shell: bash
- if: inputs.container_image_name != ''
run: echo "export DOCKER_IMAGE_NAME=${{ inputs.container_image_name }}" >> /tmp/tmp-profile
shell: bash
- if: inputs.dockerbuild_context != ''
run: echo "export DOCKERBUILD_CONTEXT=${{ inputs.dockerbuild_context }}" >> /tmp/tmp-profile
shell: bash
- run: |
current_tag=${GITHUB_REF#refs/*/}
touch /tmp/tmp-profile
. /tmp/tmp-profile
make docker DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
docker images
echo ${{ inputs.password }} | docker login -u ${{ inputs.login }} --password-stdin ${{ inputs.registry }}
make docker-publish DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-manifest DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
if [[ "$current_tag" =~ ^v[0-9]+(\.[0-9]+){2}$ ]]; then
make docker-tag-latest DOCKER_IMAGE_TAG="$current_tag" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-publish DOCKER_IMAGE_TAG="latest" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
make docker-manifest DOCKER_IMAGE_TAG="latest" DOCKER_REPO=${{ inputs.registry }}/${{ inputs.organization }}
fi
shell: bash

View File

@ -1,19 +0,0 @@
# Restore artifacts created by save_artifacts.
# Tar is used because the default actions do not preserve directory structure
# and file mode.
name: Restore artifacts
runs:
using: composite
steps:
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
with:
name: artifact
path: .artifacts
- run: |
for tar in .artifacts/*.tar
do
tar xvf $tar
done
rm -v .artifacts/*.tar
shell: bash

View File

@ -1,17 +0,0 @@
# Tar is used because the default actions do not preserve directory structure
# and file mode.
name: Save artifacts
inputs:
directory:
type: string
description: Path of the directory to save
runs:
using: composite
steps:
- run: |
tar cvf artifact.tar ${{ inputs.directory }}
mv artifact.tar artifact-$(sha1sum artifact.tar|awk '{ print $1 }').tar
shell: bash
- uses: actions/upload-artifact@v3
with:
path: artifact-*.tar

View File

@ -1,43 +0,0 @@
name: Setup environment
inputs:
enable_go:
type: boolean
description: Whether to enable go specific features, such as caching.
default: true
enable_npm:
type: boolean
description: Whether to enable npm specific features, such as caching.
default: false
enable_docker_multibuild:
type: boolean
description: Whether to enable multibuild docker
default: false
runs:
using: composite
steps:
- uses: actions/cache@v3
if: inputs.enable_go == 'true'
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/cache@v3
if: inputs.enable_npm == 'true'
with:
path: |
~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('web/ui/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- run: make promu
shell: bash
if: inputs.enable_go == 'true'
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
if: inputs.enable_docker_multibuild == 'true'
- name: Set up buildx
uses: docker/setup-buildx-action@v1
if: inputs.enable_docker_multibuild == 'true'

View File

@ -13,13 +13,14 @@ jobs:
image: quay.io/prometheus/golang-builder:1.19-base
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup_environment
- uses: prometheus/promci@v0.0.2
- uses: ./.github/promci/actions/setup_environment
- run: make GO_ONLY=1 SKIP_GOLANGCI_LINT=1
- run: go test ./tsdb/ -test.tsdb-isolation=false
- run: GOARCH=386 go test ./cmd/prometheus
- run: make -C documentation/examples/remote_storage
- run: make -C documentation/examples
- uses: ./.github/actions/check_proto
- uses: ./.github/promci/actions/check_proto
with:
version: "3.15.8"
@ -33,14 +34,15 @@ jobs:
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup_environment
- uses: prometheus/promci@v0.0.2
- uses: ./.github/promci/actions/setup_environment
with:
enable_go: false
enable_npm: true
- run: make assets-tarball
- run: make ui-lint
- run: make ui-test
- uses: ./.github/actions/save_artifacts
- uses: ./.github/promci/actions/save_artifacts
with:
directory: .tarballs
@ -101,7 +103,8 @@ jobs:
thread: [ 0, 1, 2 ]
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build
- uses: prometheus/promci@v0.0.2
- uses: ./.github/promci/actions/build
with:
promu_opts: "-p linux/amd64 -p windows/amd64 -p linux/arm64 -p darwin/amd64 -p darwin/arm64 -p linux/386"
parallelism: 3
@ -123,7 +126,8 @@ jobs:
# should also be updated.
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/build
- uses: prometheus/promci@v0.0.2
- uses: ./.github/promci/actions/build
with:
parallelism: 12
thread: ${{ matrix.thread }}
@ -157,7 +161,8 @@ jobs:
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/publish_main
- uses: prometheus/promci@v0.0.2
- uses: ./.github/promci/actions/publish_main
with:
docker_hub_login: ${{ secrets.docker_hub_login }}
docker_hub_password: ${{ secrets.docker_hub_password }}
@ -170,7 +175,8 @@ jobs:
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v2.')
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/publish_release
- uses: prometheus/promci@v0.0.2
- uses: ./.github/promci/actions/publish_release
with:
docker_hub_login: ${{ secrets.docker_hub_login }}
docker_hub_password: ${{ secrets.docker_hub_password }}
@ -184,6 +190,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: prometheus/promci@v0.0.2
- name: Install nodejs
uses: actions/setup-node@v3
with: