Migrate Jenkins workflow to Github Actions #509
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ReSDK CI | |
on: | |
push: | |
branches: | |
- master | |
tags: | |
- "[0-9]+.[0-9]+.[0-9]+*" | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
unittest: | |
runs-on: arc-runner-acopar-resolwe-bio-py | |
env: | |
TOX_COMMAND: "tox --skip-missing-interpreters false" | |
strategy: | |
fail-fast: false | |
matrix: | |
toxenv: [py38, py39, py310, py311, py312, docs, linters, package] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Assert PR is up-to-date | |
if: github.event_name == 'pull_request' | |
run: | | |
git fetch origin ${{ github.base_ref }} | |
git fetch origin HEAD --unshallow | |
git_change_target_merge_base=$(git merge-base HEAD origin/${{ github.base_ref }}) | |
git_change_target_sha=$(git rev-parse origin/${{ github.base_ref }}) | |
if [[ "${git_change_target_merge_base}" != "${git_change_target_sha}" ]]; then | |
echo 'Pull request is not up-to-date!' | |
echo "Please, rebase your pull request on top of '${{ github.base_ref }}' (commit: ${git_change_target_sha})." | |
exit 1 | |
fi | |
- name: Run Tests | |
run: > | |
${{ env.TOX_COMMAND }} -e ${{ matrix.toxenv }} | |
e2e: | |
runs-on: arc-runner-acopar-resolwe-bio-py | |
needs: unittest | |
env: | |
GENESIS_POSTGRESQL_NAME: genialis-base | |
GENESIS_POSTGRESQL_USER: genialis-base | |
GENESIS_POSTGRESQL_PASSWORD: genialis-base | |
GENESIS_POSTGRESQL_PORT: 55434 | |
GENESIS_REDIS_PORT: 56381 | |
GENESIS_RESDK_PATH: ".." | |
GENESIS_REST_THROTTLING: '{"login": "100000/hour", "credentials": "100000/hour", "email": "100000/hour"}' | |
steps: | |
- name: Checkout resolwe-bio-py | |
uses: actions/checkout@v4 | |
- name: Reset Docker credentials store | |
run: | | |
# Docker is configured to use the ecr credentials helper, | |
# which clashes with the aws-actions/configure-aws-credentials action. | |
rm -f ~/.docker/config.json | |
- name: Login to ECR | |
uses: docker/login-action@v3 | |
with: | |
registry: 396487289173.dkr.ecr.eu-west-1.amazonaws.com | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Show versions | |
run: | | |
helmfile --version | |
helm version | |
kubectl version --client | |
sops --version | |
velero version | |
- name: Create K3d cluster | |
run: | | |
ls -a | |
echo $PWD | |
cd /workdir | |
ls -a | |
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 396487289173.dkr.ecr.eu-west-1.amazonaws.com | |
# Fix authentication error by prefetching k3d base image | |
docker pull 396487289173.dkr.ecr.eu-west-1.amazonaws.com/genialis/ci/k3d-base:v1.28.8-k3s1 | |
k3d cluster create --config e2e/k3d/k3d-config.yaml | |
- name: Add hosts to /etc/hosts | |
run: | | |
sudo echo "172.18.0.2 ws.local.genialis.io local.genialis.io" | sudo tee -a /etc/hosts | |
- name: Deploy Helm charts | |
run: | | |
cd /workdir | |
helmfile -e local -f helmfile-service.yaml sync | |
- name: Authorize cluster to pull private repositories | |
run: | | |
kubectl config set-context --current --namespace=default | |
kubectl get pods | |
kubectl wait pods -l app=pod-identity-webhook --for condition=Ready --timeout=1m | |
kubectl get cronjobs | |
kubectl create job --from=cronjob/ecr-auth -n default ecr-auth-manual | |
kubectl wait --for=condition=complete --timeout=1m job/ecr-auth-manual | |
kubectl rollout restart deployment -n velero velero | |
- name: Restore Velero edge snapshot | |
run: | | |
echo "List backups" | |
velero backup get | |
echo "Restore" | |
velero restore create --include-namespaces default --from-backup edge --wait | |
echo "Get restore" | |
velero restore get | |
RESTORE_NAME=$(velero restore get | grep edge | awk '{print $1}') | |
echo "Describe restore" | |
velero restore describe $RESTORE_NAME | |
echo "Logs restore" | |
velero restore logs $RESTORE_NAME | |
- name: Try the cluster | |
run: | | |
kubectl wait --for=condition=available --timeout=1200s -n default deployment/postgres | |
kubectl rollout restart deployment asgi-server channels-manager listener background-task uploader | |
kubectl wait --for=condition=available --timeout=1200s --all deployments | |
kubectl get pods -A | |
kubectl get pvc | |
kubectl get pv | |
- name: Test curl | |
run: | | |
ping local.genialis.io -c 1 | |
- name: Run tests | |
run: | | |
# Make sure `python` refers to the tox environment's Python | |
export PATH=`pwd`/.tox/py310-e2e-resdk/bin:$PATH | |
tox --skip-missing-interpreters false -e py310-e2e-resdk | |
build: | |
runs-on: arc-runner | |
needs: [unittest, e2e] | |
if: startsWith(github.ref, 'refs/tags') | |
env: | |
PYTHON: "python3.12" | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install build | |
run: ${{ env.PYTHON }} -m pip install --user build | |
- name: Build a binary wheel and a source tarball | |
run: ${{ env.PYTHON }} -m build --sdist --wheel --outdir dist/ . | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v1 | |
with: | |
file: .coverage | |
- name: Publish distribution to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1.8 | |
with: | |
password: ${{ secrets.pypi_password }} |