From a96d46e655f1bba8122041ac2a7e3c5bc69b7e73 Mon Sep 17 00:00:00 2001 From: Skylar Simoncelli <128400943+skylar-simoncelli@users.noreply.github.com> Date: Tue, 27 Aug 2024 19:48:01 +0300 Subject: [PATCH] feat: add tests to not-earthly and fix ECR upload (#59) --- .github/workflows/not-earthly.yml | 52 +++++++++++++------------------ 1 file changed, 22 insertions(+), 30 deletions(-) diff --git a/.github/workflows/not-earthly.yml b/.github/workflows/not-earthly.yml index a2df3f5b5..026c69609 100644 --- a/.github/workflows/not-earthly.yml +++ b/.github/workflows/not-earthly.yml @@ -18,18 +18,25 @@ env: jobs: build-and-push-without-earthly: -# runs-on: [self-hosted, ubuntu] runs-on: ubuntu-latest if: github.event.action != 'closed' || github.event.pull_request.merged == true - concurrency: - group: pr-${{ github.event.pull_request.number }}-author-${{ github.event.pull_request.user.login }} - cancel-in-progress: true permissions: id-token: write contents: write steps: - name: Checkout partner-chains uses: actions/checkout@v4 + + - name: Acquire AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_ROLE_ARN_SECRET }} + aws-region: ${{ env.AWS_REGION }} + + - name: Login to ECR + uses: docker/login-action@v3 + with: + registry: ${{ secrets.ECR_REGISTRY_SECRET }} - name: Install dependencies run: | @@ -42,7 +49,11 @@ jobs: - name: Build partner-chains-node run: | cargo build -p partner-chains-node --locked --release --target x86_64-unknown-linux-gnu - cp target/x86_64-unknown-linux-gnu/release/partner-chains-node partner-chains-node + chmod +x target/x86_64-unknown-linux-gnu/release/partner-chains-node + cp target/x86_64-unknown-linux-gnu/release/partner-chains-node ./partner-chains-node + + - name: Run tests + run: cargo test --locked --release --target x86_64-unknown-linux-gnu - name: Generate Chain Specs run: | @@ -62,32 +73,13 @@ jobs: docker exec $container_id chown -R substrate:substrate /data /substrate docker exec $container_id rm -rf /usr/bin/apt* /usr/bin/dpkg* docker exec $container_id ln -s /data /substrate/.local/share/partner-chains-node + docker cp ./partner-chains-node $container_id:/usr/local/bin/partner-chains-node + docker commit --change='EXPOSE 30333 9615 9933 9944' --change='ENTRYPOINT ["/usr/local/bin/partner-chains-node"]' $container_id substrate-node:${{ github.sha }} - - name: Copy Binary to Docker Container - run: | - docker cp ./partner-chains-node ${{ env.container_id }}:/usr/local/bin/partner-chains-node - - - name: Finalize Docker Image - run: | - docker commit --change='EXPOSE 30333 9615 9933 9944' --change='ENTRYPOINT ["/usr/local/bin/partner-chains-node"]' ${{ env.container_id }} substrate/node:${{ github.sha }} - - - name: Acquire AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - if: ${{ github.event.pull_request.merged == true && !contains(github.event.pull_request.labels.*.name, 'ci-off') }} - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN_SECRET }} - aws-region: ${{ env.AWS_REGION }} - - - name: Login to ECR - uses: docker/login-action@v3 - if: ${{ github.event.pull_request.merged == true && !contains(github.event.pull_request.labels.*.name, 'ci-off') }} - with: - registry: ${{ secrets.ECR_REGISTRY_SECRET }} - - - name: Push to Docker Registry - if: ${{ github.event.pull_request.merged == true && !contains(github.event.pull_request.labels.*.name, 'ci-off') }} + - name: Push to ECR run: | - docker push substrate/node:${{ github.sha }} + docker tag substrate-node:${{ github.sha }} ${{ secrets.ECR_REGISTRY_SECRET }}/substrate-node:${{ github.sha }} + docker push ${{ secrets.ECR_REGISTRY_SECRET }}/substrate-node:${{ github.sha }} - name: Cleanup Docker Container if: always() @@ -179,7 +171,7 @@ jobs: chain-specs: runs-on: [self-hosted, eks] needs: [build-and-push-without-earthly] - if: github.ref_name == 'master' || inputs.upload == true + if: ${{ github.event.pull_request.merged == true && !contains(github.event.pull_request.labels.*.name, 'ci-off') }} permissions: id-token: write contents: write