diff --git a/.github/workflows/check.yaml b/.github/workflows/check_main.yaml similarity index 54% rename from .github/workflows/check.yaml rename to .github/workflows/check_main.yaml index c23e1378..046079eb 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check_main.yaml @@ -45,55 +45,13 @@ jobs: needs: - start-vm - checkout - runs-on: ${{ needs.start-vm.outputs.label }} - env: - HOME: /root - steps: - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.19 - - - name: Set up Helm - uses: azure/setup-helm@v1 - with: - version: v3.11.2 - - - name: Build - shell: bash - run: | - make build - - - name: Run tests - shell: bash - run: | - [ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.19.0/kind-linux-amd64 - chmod +x ./kind - sudo mv ./kind /usr/local/bin/kind - kind create cluster --retain -v 100 - kubectl get pod - kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml - - make helm-kind-install - docker pull ytsaurus/ytsaurus-nightly:dev-23.1-5f8638fc66f6e59c7a06708ed508804986a6579f - kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.1-5f8638fc66f6e59c7a06708ed508804986a6579f - docker pull ytsaurus/ytsaurus-nightly:dev-23.1-9779e0140ff73f5a786bd5362313ef9a74fcd0de - kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.1-9779e0140ff73f5a786bd5362313ef9a74fcd0de - docker pull ytsaurus/ytsaurus-nightly:dev-23.2-62a472c4efc2c8395d125a13ca0216720e06999d - kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.2-62a472c4efc2c8395d125a13ca0216720e06999d - YTSAURUS_ENABLE_E2E_TESTS=true make test - helm uninstall ytsaurus - - ./compat_test.sh --from-version 0.4.1 --to-version trunk - - - name: Docker Hub login - run: | - echo '${{ secrets.DOCKER_HUB_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_HUB_LOGIN}} --password-stdin - - - name: Docker - shell: bash - run: | - make release RELEASE_VERSION=0.0.$(git rev-list --count HEAD)-dev-${GITHUB_SHA} OPERATOR_IMAGE=ytsaurus/k8s-operator-nightly OPERATOR_CHART=ytop-chart-nightly + with: + runs-on-value: ${{ needs.start-vm.outputs.label }} + release: true + secrets: + DOCKER_HUB_LOGIN: ${{ secrets.DOCKER_HUB_LOGIN }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + uses: ./.github/workflows/subflow_run_e2e.yaml stop-vm: name: Stop VM diff --git a/.github/workflows/check_pr.yaml b/.github/workflows/check_pr.yaml new file mode 100644 index 00000000..e4e6fadc --- /dev/null +++ b/.github/workflows/check_pr.yaml @@ -0,0 +1,70 @@ +name: Build and test + +on: + pull_request: + +jobs: + start-vm: + if: github.event.pull_request.head.repo.full_name == github.repository + name: Start VM + runs-on: ubuntu-latest + outputs: + label: ${{ steps.start-yc-runner.outputs.label }} + instance-id: ${{ steps.start-yc-runner.outputs.instance-id }} + steps: + - name: Start YC runner + id: start-yc-runner + uses: yc-actions/yc-github-runner@v1 + with: + mode: start + yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }} + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + folder-id: ${{ vars.YC_FOLDER_ID }} + image-id: ${{ vars.YC_DEFAULT_IMAGE_ID }} + zone-id: ${{ vars.YC_ZONE_ID }} + subnet-id: ${{ vars.YC_SUBNET_ID }} + cores: 4 + memory: 8GB + core-fraction: 100 + disk-type: network-ssd-nonreplicated + disk-size: 93GB + + checkout: + name: Checkout sources + needs: start-vm + runs-on: ${{ needs.start-vm.outputs.label }} + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + check: + name: Run checks + needs: + - start-vm + - checkout + with: + runs-on-value: ${{ needs.start-vm.outputs.label }} + release: false + secrets: + DOCKER_HUB_LOGIN: ${{ secrets.DOCKER_HUB_LOGIN }} + DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} + uses: ./.github/workflows/subflow_run_e2e.yaml + + stop-vm: + name: Stop VM + needs: + - start-vm + - check + runs-on: ubuntu-latest + if: ${{ always() }} + steps: + - name: Stop YC runner + uses: yc-actions/yc-github-runner@v1 + with: + mode: stop + yc-sa-json-credentials: ${{ secrets.YC_SA_JSON_CREDENTIALS }} + github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }} + label: ${{ needs.start-vm.outputs.label }} + instance-id: ${{ needs.start-vm.outputs.instance-id }} diff --git a/.github/workflows/subflow_run_e2e.yaml b/.github/workflows/subflow_run_e2e.yaml new file mode 100644 index 00000000..031b6508 --- /dev/null +++ b/.github/workflows/subflow_run_e2e.yaml @@ -0,0 +1,69 @@ +on: + workflow_call: + inputs: + runs-on-value: + required: true + type: string + release: + required: true + type: boolean + secrets: + DOCKER_HUB_LOGIN: + required: true + DOCKER_HUB_PASSWORD: + required: true + +jobs: + check: + name: Run checks + runs-on: ${{ inputs.runs-on-value }} + env: + HOME: /root + steps: + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + + - name: Set up Helm + uses: azure/setup-helm@v1 + with: + version: v3.11.2 + + - name: Build + shell: bash + run: | + make build + + - name: Run tests + shell: bash + run: | + [ $(uname -m) = x86_64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.19.0/kind-linux-amd64 + chmod +x ./kind + sudo mv ./kind /usr/local/bin/kind + kind create cluster --retain -v 100 + kubectl get pod + kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.11.0/cert-manager.yaml + + make helm-kind-install + docker pull ytsaurus/ytsaurus-nightly:dev-23.1-5f8638fc66f6e59c7a06708ed508804986a6579f + kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.1-5f8638fc66f6e59c7a06708ed508804986a6579f + docker pull ytsaurus/ytsaurus-nightly:dev-23.1-9779e0140ff73f5a786bd5362313ef9a74fcd0de + kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.1-9779e0140ff73f5a786bd5362313ef9a74fcd0de + docker pull ytsaurus/ytsaurus-nightly:dev-23.2-62a472c4efc2c8395d125a13ca0216720e06999d + kind load docker-image ytsaurus/ytsaurus-nightly:dev-23.2-62a472c4efc2c8395d125a13ca0216720e06999d + YTSAURUS_ENABLE_E2E_TESTS=true make test + helm uninstall ytsaurus + + ./compat_test.sh --from-version 0.4.1 --to-version trunk + + - name: Docker Hub login + if: ${{ inputs.release }} + run: | + echo '${{ secrets.DOCKER_HUB_PASSWORD }}' | docker login --username ${{ secrets.DOCKER_HUB_LOGIN}} --password-stdin + + - name: Docker + if: ${{ inputs.release }} + shell: bash + run: | + make release RELEASE_VERSION=0.0.$(git rev-list --count HEAD)-dev-${GITHUB_SHA} OPERATOR_IMAGE=ytsaurus/k8s-operator-nightly OPERATOR_CHART=ytop-chart-nightly