Skip to content

Commit

Permalink
feat: added correctness test
Browse files Browse the repository at this point in the history
fix: debug docker

fix: debug docker

fix: steps in setup

fix: steps in setup

fix: use root in Docker file

fix: use root in Docker file

fix: curl the file

fix: hermetic-driver flavor

fix: yq colors and debug

fix: yq colors and debug

fix: update network name and cleanup

fix: update network name and cleanup

feat: use pr comit for image tag
  • Loading branch information
3benbox committed Jan 31, 2024
1 parent 84fa5e3 commit c8ffc41
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
86 changes: 86 additions & 0 deletions .github/workflows/rust-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ jobs:
run: make test
build:
runs-on: ubuntu-latest
outputs:
build_tag: ${{ steps.build.outputs.build_tag }}
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -99,5 +101,89 @@ jobs:
echo "PROTOC_INCLUDE=/usr/local/include" >> $GITHUB_ENV
- name: Build
run: make build
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Public ECR
uses: docker/login-action@v2
with:
registry: public.ecr.aws
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
env:
AWS_REGION: us-east-1
-
name: Build and Publish Docker Image
id: build
run: |
SHA_TAG=$(echo ${{ github.SHA }} | head -c 12)
BUILD_TAG=$SHA_TAG
COMMIT_MESSAGE=$(git log -1 --pretty=%B)
if [[ $(echo "$COMMIT_MESSAGE" | grep 'chore: version v') ]]; then
RELEASE_TAG=$(cargo metadata --format-version=1 --no-deps | jq '.packages[0].version' | tr -d '"')
# Use the release tag to deploy, if one is available.
BUILD_TAG=$RELEASE_TAG
fi
if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "main" ]]; then
# Use PR commit sha on PRs for main
RELEASE_TAG=$(echo ${{ github.event.pull_request.head.sha }} | head -c 12)
BUILD_TAG=$RELEASE_TAG
fi
make SHA="${{ github.SHA }}" SHA_TAG="$SHA_TAG" RELEASE_TAG="$RELEASE_TAG" publish-docker
echo "Build tag:"
echo ${BUILD_TAG}
echo "build_tag=${BUILD_TAG}" >> $GITHUB_OUTPUT
correctness-tests:
runs-on: ubuntu-latest
environment: github-tests-2024
needs:
- build
steps:
- uses: actions/checkout@v3
-
name: Setup GKE auth
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GKE_SA_KEY }}
-
name: Get GKE credentials
uses: 'google-github-actions/get-gke-credentials@v1'
with:
cluster_name: ${{ vars.GKE_CLUSTER }}
location: ${{ vars.GKE_ZONE }}

-
name: Get Network template and update
env:
RUST_CERAMIC_IMAGE_TAG: ${{ needs.build.outputs.build_tag }}
RUST_CERAMIC_IMAGE_REPO: public.ecr.aws/r5b3e0r5/3box/ceramic-one
run: |
set -ex
export RUST_CERAMIC_IMAGE=${RUST_CERAMIC_IMAGE_REPO}:${RUST_CERAMIC_IMAGE_TAG}
export KERAMIK_NETWORK_NAME=hermetic-rust-ceramic-${RUST_CERAMIC_IMAGE_TAG}
echo "KERAMIK_NETWORK_NAME=${KERAMIK_NETWORK_NAME}" >> "$GITHUB_ENV"
mkdir ./bin
sudo apt-get update && sudo apt-get install -y curl
curl -L https://github.com/mikefarah/yq/releases/download/v4.40.5/yq_linux_amd64 -o ./bin/yq
chmod +x ./bin/yq
curl -L https://github.com/3box/ceramic-tests/releases/download/v0.2.0/hermetic-driver-x86_64-linux -o ./bin/hermetic-driver
chmod +x ./bin/hermetic-driver
curl -LO https://raw.githubusercontent.com/3box/ceramic-tests/main/networks/basic-rust.yaml
./bin/yq -i '.spec.ceramic[0].ipfs.rust.image = strenv(RUST_CERAMIC_IMAGE)' basic-rust.yaml
./bin/yq -i '.metadata.name = strenv(KERAMIK_NETWORK_NAME)' basic-rust.yaml
./bin/yq --no-colors basic-rust.yaml
-
name: Run correctness-tests
run: |
./bin/hermetic-driver test \
--network basic-rust.yaml \
--flavor correctness \
--test-selector "fast"
-
name: Clean up correctness-test
run: |
echo "Removing network ${KERAMIK_NETWORK_NAME}"
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ WORKDIR /home/builder/rust-ceramic
# Use the same ids as the parent docker image by default
ARG UID=1001
ARG GID=1001

USER root
# Define the type of build to make. One of release or debug.
ARG BUILD_MODE=release

Expand Down

0 comments on commit c8ffc41

Please sign in to comment.