From 42509bc106da4873ddb5120efc6d1193425a3f39 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Tue, 20 Dec 2022 09:40:31 +0100 Subject: [PATCH] Switch to promci Reuse common actions Signed-off-by: Julien Pivotto --- .github/actions/build/action.yml | 23 -------- .github/actions/check_proto/action.yml | 20 ------- .github/actions/publish_images/action.yml | 47 ---------------- .github/actions/publish_main/action.yml | 43 --------------- .github/actions/publish_release/action.yml | 54 ------------------- .../actions/publish_release_images/action.yml | 53 ------------------ .github/actions/restore_artifacts/action.yml | 19 ------- .github/actions/save_artifacts/action.yml | 17 ------ .github/actions/setup_environment/action.yml | 43 --------------- .github/workflows/ci.yml | 23 +++++--- 10 files changed, 15 insertions(+), 327 deletions(-) delete mode 100644 .github/actions/build/action.yml delete mode 100644 .github/actions/check_proto/action.yml delete mode 100644 .github/actions/publish_images/action.yml delete mode 100644 .github/actions/publish_main/action.yml delete mode 100644 .github/actions/publish_release/action.yml delete mode 100644 .github/actions/publish_release_images/action.yml delete mode 100644 .github/actions/restore_artifacts/action.yml delete mode 100644 .github/actions/save_artifacts/action.yml delete mode 100644 .github/actions/setup_environment/action.yml diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml deleted file mode 100644 index 7b8e3605f..000000000 --- a/.github/actions/build/action.yml +++ /dev/null @@ -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 diff --git a/.github/actions/check_proto/action.yml b/.github/actions/check_proto/action.yml deleted file mode 100644 index 9d9d773e6..000000000 --- a/.github/actions/check_proto/action.yml +++ /dev/null @@ -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 diff --git a/.github/actions/publish_images/action.yml b/.github/actions/publish_images/action.yml deleted file mode 100644 index bc17eb7d9..000000000 --- a/.github/actions/publish_images/action.yml +++ /dev/null @@ -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 diff --git a/.github/actions/publish_main/action.yml b/.github/actions/publish_main/action.yml deleted file mode 100644 index 3ff45c20a..000000000 --- a/.github/actions/publish_main/action.yml +++ /dev/null @@ -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 }} diff --git a/.github/actions/publish_release/action.yml b/.github/actions/publish_release/action.yml deleted file mode 100644 index 1b6a0e302..000000000 --- a/.github/actions/publish_release/action.yml +++ /dev/null @@ -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 }} diff --git a/.github/actions/publish_release_images/action.yml b/.github/actions/publish_release_images/action.yml deleted file mode 100644 index 3b6132894..000000000 --- a/.github/actions/publish_release_images/action.yml +++ /dev/null @@ -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 diff --git a/.github/actions/restore_artifacts/action.yml b/.github/actions/restore_artifacts/action.yml deleted file mode 100644 index a2d1b625e..000000000 --- a/.github/actions/restore_artifacts/action.yml +++ /dev/null @@ -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 diff --git a/.github/actions/save_artifacts/action.yml b/.github/actions/save_artifacts/action.yml deleted file mode 100644 index e0b0440d0..000000000 --- a/.github/actions/save_artifacts/action.yml +++ /dev/null @@ -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 diff --git a/.github/actions/setup_environment/action.yml b/.github/actions/setup_environment/action.yml deleted file mode 100644 index 8c1d4d58e..000000000 --- a/.github/actions/setup_environment/action.yml +++ /dev/null @@ -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' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26a9c8b8b..98c771e86 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: