From c7a0b75aa6a1d75983fd4ca7bafe7ecde677f2e4 Mon Sep 17 00:00:00 2001 From: Anatolios Laskaris Date: Fri, 9 Jun 2023 16:18:39 +0300 Subject: [PATCH] chore: Add distro to e2e (#147) * Update snapshot build * Fix * Fix * Fix * Add fluence-cli to tests * Fix * Debug * fix * Use debug branch * Fix * Use main --- .github/workflows/container.yml | 48 ++++++++++--------- .github/workflows/e2e.yml | 82 +++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 9 ++++ .github/workflows/snapshot.yml | 34 -------------- 4 files changed, 117 insertions(+), 56 deletions(-) create mode 100644 .github/workflows/e2e.yml delete mode 100644 .github/workflows/snapshot.yml diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index adafc48..eb8f4aa 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -10,23 +10,24 @@ on: version: description: "version set as part of container tag" type: string + flavour: + description: "nox flavour" + type: string + default: "minimal" release: description: "if triggered by release workflow" type: boolean default: false + outputs: + nox-image: + description: "nox snapshot image" + value: ${{ jobs.build.outputs.image }} jobs: build: - name: "Build and push ${{ matrix.package }}" + name: "Build and push ${{ inputs.flavour }}" runs-on: ubuntu-latest - strategy: - matrix: - package: - - minimal - - ipfs - - rich - # for authentication to Vault with vault-action # https://github.com/hashicorp/vault-action#jwt-with-github-oidc-tokens permissions: @@ -36,6 +37,9 @@ jobs: env: RELEASE_VERSION: ${{ inputs.version }} + outputs: + image: "${{ inputs.image }}@${{ steps.docker.outputs.digest }}" + steps: - name: Set build date run: echo "BUILD_DATE=$(date '+%Y-%m-%dT%H:%M:%S%:z')" >> $GITHUB_ENV @@ -89,16 +93,16 @@ jobs: username: ${{ env.DOCKER_USERNAME }} password: ${{ env.DOCKER_PASSWORD }} - - name: Build and push ${{ matrix.package }} + - name: Build and push ${{ inputs.flavour }} id: docker uses: docker/build-push-action@v3 with: context: . push: true - target: ${{ matrix.package }} + target: ${{ inputs.flavour }} tags: | - ${{ inputs.image }}:${{ matrix.package }} - ${{ inputs.image }}:${{ matrix.package }}_${{ env.RELEASE_VERSION }} + ${{ inputs.image }}:${{ inputs.flavour }} + ${{ inputs.image }}:${{ inputs.flavour }}_${{ env.RELEASE_VERSION }} labels: | org.opencontainers.image.version=${{ env.RELEASE_VERSION }} org.opencontainers.image.created=${{ env.BUILD_DATE }} @@ -106,16 +110,16 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - - name: Build and push ${{ matrix.package }} (legacy) + - name: Build and push ${{ inputs.flavour }} (legacy) if: inputs.release uses: docker/build-push-action@v3 with: context: . push: true - target: ${{ matrix.package }} + target: ${{ inputs.flavour }} tags: | - fluencelabs/rust-peer:${{ matrix.package }} - fluencelabs/rust-peer:${{ matrix.package }}_${{ env.RELEASE_VERSION }} + fluencelabs/rust-peer:${{ inputs.flavour }} + fluencelabs/rust-peer:${{ inputs.flavour }}_${{ env.RELEASE_VERSION }} labels: | org.opencontainers.image.version=${{ env.RELEASE_VERSION }} org.opencontainers.image.created=${{ env.BUILD_DATE }} @@ -123,13 +127,13 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max - - name: Build and push ${{ matrix.package }} + - name: Build and push ${{ inputs.flavour }} if: ${{ matrix.package == 'ipfs' && inputs.release }} uses: docker/build-push-action@v3 with: context: . push: true - target: ${{ matrix.package }} + target: ${{ inputs.flavour }} tags: | ${{ inputs.image }}:latest ${{ inputs.image }}:${{ env.RELEASE_VERSION }} @@ -143,7 +147,7 @@ jobs: cache-to: type=gha,mode=max - name: Docker Hub Description - if: ${{ matrix.package == 'ipfs' && inputs.release }} + if: ${{ inputs.flavour == 'ipfs' && inputs.release }} uses: peter-evans/dockerhub-description@v3 with: username: ${{ env.DOCKER_USERNAME }} @@ -154,10 +158,10 @@ jobs: if: always() run: | cat <<'SNAPSHOT' >> $GITHUB_STEP_SUMMARY - ## nox ${{ matrix.package }} + ## nox ${{ inputs.flavour }} digest: `${{ steps.docker.outputs.digest }}` ``` - ${{ inputs.image }}:${{ matrix.package }} - ${{ inputs.image }}:${{ matrix.package }}_${{ env.RELEASE_VERSION }} + ${{ inputs.image }}:${{ inputs.flavour }} + ${{ inputs.image }}:${{ inputs.flavour }}_${{ env.RELEASE_VERSION }} ``` SNAPSHOT diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml new file mode 100644 index 0000000..b65c337 --- /dev/null +++ b/.github/workflows/e2e.yml @@ -0,0 +1,82 @@ +name: "e2e" + +on: + pull_request: + paths-ignore: + - "**.md" + - ".github/**" + - "!.github/workflows/e2e.yml" + - "!.github/workflows/container.yml" + types: + - "labeled" + - "synchronize" + - "opened" + - "reopened" + push: + branches: + - "master" + paths-ignore: + - "**.md" + - ".github/**" + - "!.github/workflows/e2e.yml" + - "!.github/workflows/container.yml" + +env: + DOCKER_BUILDKIT: 1 + FORCE_COLOR: 1 + +jobs: + version: + name: "Generate snapshot id" + runs-on: ubuntu-latest + if: > + github.event_name == 'push' || + ( + contains(github.event.pull_request.labels.*.name, 'e2e') && + !github.event.pull_request.head.repo.fork + ) + outputs: + id: ${{ steps.version.outputs.id }} + steps: + - name: Generate snapshot version + id: version + uses: fluencelabs/github-actions/generate-snapshot-id@main + + flavours: + name: "snapshot" + needs: version + strategy: + matrix: + flavour: + - ipfs + - rich + + permissions: + contents: read + id-token: write + + uses: ./.github/workflows/container.yml + with: + image: "docker.fluence.dev/nox-distro" + flavour: ${{ matrix.flavour }} + version: ${{ needs.version.outputs.id }} + + snapshot: + needs: version + + permissions: + contents: read + id-token: write + + uses: ./.github/workflows/container.yml + with: + image: "docker.fluence.dev/nox-distro" + flavour: minimal + version: ${{ needs.version.outputs.id }} + + fluence-cli: + needs: + - snapshot + uses: fluencelabs/fluence-cli/.github/workflows/tests.yml@main + with: + rust-peer-image: "${{ needs.snapshot.outputs.nox-image }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d6a7bed..f9a6a37 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,12 +38,21 @@ jobs: publish: if: needs.release-please.outputs.release-created needs: release-please + strategy: + matrix: + flavour: + - minimal + - ipfs + - rich + permissions: contents: read id-token: write + uses: ./.github/workflows/container.yml with: version: ${{ needs.release-please.outputs.version }} + flavour: ${{ matrix.flavour }} release: true update-release: diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml deleted file mode 100644 index 54740a6..0000000 --- a/.github/workflows/snapshot.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: "snapshot" - -on: - pull_request: - paths-ignore: - - "!**.md" - push: - branches: - - "main" - -env: - DOCKER_BUILDKIT: 1 - FORCE_COLOR: 1 - -jobs: - version: - name: "Generate snapshot id" - runs-on: ubuntu-latest - outputs: - id: ${{ steps.version.outputs.id }} - steps: - - name: Generate snapshot version - id: version - uses: fluencelabs/github-actions/generate-snapshot-id@main - - snapshot: - needs: version - permissions: - contents: read - id-token: write - uses: ./.github/workflows/container.yml - with: - image: "docker.fluence.dev/distro" - version: ${{ needs.version.outputs.id }}