Skip to content

Commit

Permalink
add action to determine docekr image tag name and fix helm workflow
Browse files Browse the repository at this point in the history
Signed-off-by: hlts2 <hiroto.funakoshi.hiroto@gmail.com>
  • Loading branch information
hlts2 committed Aug 3, 2023
1 parent a183f7b commit dbfa45b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 95 deletions.
38 changes: 38 additions & 0 deletions .github/actions/determine-docker-image-tag/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Determine Docker image tag"
description: "Determine Docker image tag"

outputs:
PRIMARY_TAG:
description: "primary tag"
value: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }}

runs:
using: "composite"
steps:
- name: Determine tag name
shell: bash
id: determine_tag_name
run: |
echo "GITHUB_REF $GITHUB_REF"
echo "GITHUB_EVENT_PATH $GITHUB_EVENT_PATH"
echo "GITHUB_EVENT_NAME ${{ github.event_name }}"
echo "GITHUB_EVENT_NUMBER ${{ github.event.number }}"
if [[ "$GITHUB_REF" =~ ^refs/tags/.* ]]; then
tag_name=`echo $GITHUB_REF | sed -e 's:^refs/tags/::'`
primary_tag="${tag_name}"
elif [ "${{ github.event_name }}" = "pull_request" ]; then
pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"`
echo "PR-${pr_num}" > versions/VALD_VERSION
primary_tag="pr-${pr_num}"
elif [ "${{ github.event_name }}" = "pull_request_target" ]; then
pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"`
echo "PR-${pr_num}" > versions/VALD_VERSION
primary_tag="pr-${pr_num}"
elif [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "nightly" > versions/VALD_VERSION
primary_tag="nightly"
else
primary_tag="unknown"
fi
echo "PRIMARY_TAG is determined: ${primary_tag}"
echo "PRIMARY_TAG=${primary_tag}" >> $GITHUB_OUTPUT
28 changes: 2 additions & 26 deletions .github/actions/docker-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,9 @@ runs:
env:
TARGET: ${{ inputs.target }}

- name: Determine tag name
shell: bash
- name: Determine Docker image tag
id: determine_tag_name
run: |
echo "GITHUB_REF $GITHUB_REF"
echo "GITHUB_EVENT_PATH $GITHUB_EVENT_PATH"
echo "GITHUB_EVENT_NAME ${{ github.event_name }}"
echo "GITHUB_EVENT_NUMBER ${{ github.event.number }}"
if [[ "$GITHUB_REF" =~ ^refs/tags/.* ]]; then
tag_name=`echo $GITHUB_REF | sed -e 's:^refs/tags/::'`
primary_tag="${tag_name}"
elif [ "${{ github.event_name }}" = "pull_request" ]; then
pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"`
echo "PR-${pr_num}" > versions/VALD_VERSION
primary_tag="pr-${pr_num}"
elif [ "${{ github.event_name }}" = "pull_request_target" ]; then
pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"`
echo "PR-${pr_num}" > versions/VALD_VERSION
primary_tag="pr-${pr_num}"
elif [ "$GITHUB_REF" = "refs/heads/main" ]; then
echo "nightly" > versions/VALD_VERSION
primary_tag="nightly"
else
primary_tag="unknown"
fi
echo "PRIMARY_TAG is determined: ${primary_tag}"
echo "PRIMARY_TAG=${primary_tag}" >> $GITHUB_OUTPUT
uses: ./.github/actions/determine-docker-image-tag

- name: Determine platforms
shell: bash
Expand Down
16 changes: 5 additions & 11 deletions .github/actions/setup-e2e/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,21 @@ runs:
- name: Setup Helm environment
uses: ./.github/actions/setup-helm

- name: Get PR number
# TODO: add if statement
id: get_pr_number
shell: bash
run: |
pr_num=`cat $GITHUB_EVENT_PATH | jq -r ".number"`
echo "PR_NUM=${pr_num}" >> $GITHUB_OUTPUT
- name: Wait for target Docker images
if: startsWith( github.ref, 'refs/tags/')
uses: ./.github/actions/wait-for-docker-image
with:
images: ${{ inputs.target_images }}

- name: Determine Docker image tag
id: determine_tag_name
uses: ./.github/actions/determine-docker-image-tag

- name: Specify container versions
id: specify_container_versions
uses: ./.github/actions/detect-docker-image-tags
with:
# TODO: Change it later
# tag_name: pr-${{ steps.get_pr_number.outputs.PR_NUM }}
tag_name: nightly
tag_name: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }}
images: ${{ inputs.target_images }}

- uses: ./.github/actions/setup-k3d
Expand Down
74 changes: 16 additions & 58 deletions .github/workflows/helm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,11 @@ jobs:
container:
image: ghcr.io/vdaas/vald/vald-ci-container:nightly
steps:
- name: Check out code.
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: set git config
- name: Set Git config
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
Expand All @@ -50,11 +49,10 @@ jobs:
git_user_signingkey: true
git_commit_gpgsign: true

- name: Helm version
run: |
helm version
- name: Setup Helm environment
uses: ./.github/actions/setup-helm

- name: switch new branch
- name: Switch new branch
id: switch_to_new_branch
run: |
TIMESTAMP=$(date +%Y%m%d_%H%M%S_%3N)
Expand Down Expand Up @@ -101,13 +99,12 @@ jobs:
container:
image: ghcr.io/vdaas/vald/vald-ci-container:nightly
steps:
- name: Check out code.
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.DISPATCH_TOKEN }}

- name: set git config
- name: Set Git config
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
Expand All @@ -117,9 +114,8 @@ jobs:
git_user_signingkey: true
git_commit_gpgsign: true

- name: Helm version
run: |
helm version
- name: Setup Helm environment
uses: ./.github/actions/setup-helm

- name: Packaging
run: |
Expand Down Expand Up @@ -149,66 +145,28 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: set git config
- name: Set Git config
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
- name: Wait for Docker images
id: wait_for_docker_images
uses: ./.github/actions/wait-for-docker-image

- name: Specify container versions
id: specify_container_versions
uses: ./.github/actions/detect-docker-image-tags
- name: Setup E2E environment
id: setup_e2e
uses: ./.github/actions/setup-e2e
with:
tag_name: ${{ github.ref_name }}

- name: Fetch Helm version
run: |
HELM_VERSION=`make version/helm`
echo "helm=${HELM_VERSION}" >> $GITHUB_OUTPUT
id: version

- uses: ./.github/actions/setup-k3d
with:
agents: 3

- name: check k3d
run: |
kubectl cluster-info
- uses: azure/setup-helm@v3
with:
version: ${{ steps.version.outputs.helm }}

- name: Helm version
run: |
helm version
require_libhdf5: "true"

- name: deploy Vald
- name: Deploy Vald
id: deploy_vald
uses: ./.github/actions/e2e-deploy-vald
with:
require_libhdf5: "true"
helm_extra_options: ${{ steps.specify_container_versions.outputs.HELM_EXTRA_OPTIONS }}
helm_extra_options: ${{ steps.setup_e2e.outputs.HELM_EXTRA_OPTIONS }}
values: .github/helm/values/values-lb.yaml
wait_for_selector: app=vald-lb-gateway
use_local_charts: false

- name: Fetch golang version
run: |
GO_VERSION=`make version/go`
echo "version=${GO_VERSION}" >> $GITHUB_OUTPUT
id: golang_version

- uses: actions/setup-go@v3
with:
go-version: ${{ steps.golang_version.outputs.version }}

- name: Run E2E CRUD
run: |
make hack/benchmark/assets/dataset/${DATASET}
go version
make E2E_BIND_PORT=8081 \
E2E_DATASET_NAME=${DATASET} \
E2E_INSERT_COUNT=60000 \
Expand Down

0 comments on commit dbfa45b

Please sign in to comment.