diff --git a/.github/workflows/ci-release-TEMPLATE.yml b/.github/workflows/ci-release-TEMPLATE.yml new file mode 100644 index 0000000000..0a2e6a0846 --- /dev/null +++ b/.github/workflows/ci-release-TEMPLATE.yml @@ -0,0 +1,410 @@ +name: Garage CI + +env: + GARAGE_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + TRAVIS_COMMIT_RANGE: origin/${{ github.base_ref }}...origin/${{ github.head_ref }} + DOCKER_TAG: garage-ci-${{ github.run_id }} + OWNER: "rlworkgroup" + DOCKER_CACHE_REPO: "garage-ci" + MJKEY: ${{ secrets.MJKEY }} + CI_USER: rlworkgroupbot + +on: +# schedule: +# - cron: '0 9 * * *' +# pull-request: +# branches: +# - '' + +jobs: + build_docker_container: + name: Build Docker Container + runs-on: ubuntu-latest + + steps: + - name: Docker info + run: docker version + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Build Docker container + run: | + docker build . \ + -f docker/Dockerfile \ + --target garage-dev-18.04 \ + -t "${DOCKER_TAG}" \ + --build-arg GARAGE_GH_TOKEN \ + --cache-from="docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Push to cache (GitHub Package Registry) + run: | + docker tag "${DOCKER_TAG}" "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + docker push "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + + + check_pre_commit: + name: Check pre-commit + runs-on: ubuntu-latest + needs: build_docker_container + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + if: github.event_name == 'pull_request' + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Pull from cache (GitHub Package Registry) + if: github.event_name == 'pull_request' + run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Tag docker image + if: github.event_name == 'pull_request' + run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: Check pre-commit + if: github.event_name == 'pull_request' + run: | + docker run \ + -e TRAVIS_COMMIT_RANGE \ + -e MJKEY \ + --memory 6500m \ + --memory-swap 6500m \ + "${DOCKER_TAG}" scripts/travisci/check_precommit.sh + + + normal_test: + name: Normal Tests + runs-on: ubuntu-latest + needs: check_pre_commit + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Pull from cache (GitHub Package Registry) + run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Tag docker image + run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: Normal tests + run: | + ci_env="$(bash <(curl -s https://codecov.io/env))" && + docker run \ + -e TRAVIS_COMMIT_RANGE \ + -e MJKEY \ + -e GITHUB_ACTIONS \ + -e CODECOV_TOKEN \ + $ci_env\ + --memory 6500m \ + --memory-swap 6500m \ + "${DOCKER_TAG}" \ + /bin/bash -c \ + '[ ! -f ${MJKEY_PATH} ] || mv ${MJKEY_PATH} ${MJKEY_PATH}.bak && + pytest --cov=garage --cov-report=xml -m \ + "not nightly and not huge and not flaky and not large and not mujoco and not mujoco_long" --durations=20 && + for i in {1..5}; do + bash <(curl -s https://codecov.io/bash --retry 5) -Z && break + if [ $i == 5 ]; then + exit 1 + else + echo "Retry ${i}..." + sleep 30 + fi + done' + + + large_test: + name: Large Tests + runs-on: ubuntu-latest + needs: check_pre_commit + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Pull from cache (GitHub Package Registry) + run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Tag docker image + run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: Large tests + run: | + ci_env="$(bash <(curl -s https://codecov.io/env))" && + docker run \ + -e TRAVIS_COMMIT_RANGE \ + -e MJKEY \ + -e GITHUB_ACTIONS \ + -e CODECOV_TOKEN \ + $ci_env\ + --memory 6500m \ + --memory-swap 6500m \ + "${DOCKER_TAG}" \ + /bin/bash -c \ + '[ ! -f ${MJKEY_PATH} ] || mv ${MJKEY_PATH} ${MJKEY_PATH}.bak && + pytest --cov=garage --cov-report=xml -m "large and not flaky" --durations=20 && + for i in {1..5}; do + bash <(curl -s https://codecov.io/bash --retry 5) -Z && break + if [ $i == 5 ]; then + exit 1 + else + echo "Retry ${i}..." + sleep 30 + fi + done' + + + mujoco_test: + name: MuJoCo-Based Tests + runs-on: ubuntu-latest + needs: check_pre_commit + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Pull from cache (GitHub Package Registry) + run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Tag docker image + run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: MuJoCo tests + run: | + ci_env="$(bash <(curl -s https://codecov.io/env))" && + docker run \ + -e TRAVIS_COMMIT_RANGE \ + -e MJKEY \ + -e GITHUB_ACTIONS \ + -e CODECOV_TOKEN \ + $ci_env\ + --memory 6500m \ + --memory-swap 6500m \ + "${DOCKER_TAG}" \ + /bin/bash -c \ + 'pytest --cov=garage --cov-report=xml -m "mujoco and not flaky" --durations=20 && + for i in {1..5}; do + bash <(curl -s https://codecov.io/bash --retry 5) -Z && break + if [ $i == 5 ]; then + exit 1 + else + echo "Retry ${i}..." + sleep 30 + fi + done' + + + mujoco_test_long: + name: Large MuJoCo-Based Tests + runs-on: ubuntu-latest + needs: check_pre_commit + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Pull from cache (GitHub Package Registry) + run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Tag docker image + run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: Large MuJoCo tests + run: | + ci_env="$(bash <(curl -s https://codecov.io/env))" && + docker run \ + -e TRAVIS_COMMIT_RANGE \ + -e MJKEY \ + -e GITHUB_ACTIONS \ + -e CODECOV_TOKEN \ + $ci_env\ + --memory 6500m \ + --memory-swap 6500m \ + "${DOCKER_TAG}" \ + /bin/bash -c \ + 'pytest --cov=garage --cov-report=xml -m "mujoco_long and not flaky" --durations=20 && + for i in {1..5}; do + bash <(curl -s https://codecov.io/bash --retry 5) -Z && break + if [ $i == 5 ]; then + exit 1 + else + echo "Retry ${i}..." + sleep 30 + fi + done' + + + nightly_test: + name: Nightly Tests + runs-on: ubuntu-latest + needs: build_docker_container + if: github.event_name == 'schedule' + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Pull from cache (GitHub Package Registry) + run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Tag docker image + run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: Nightly tests + run: | + ci_env="$(bash <(curl -s https://codecov.io/env))" && + docker run \ + -e TRAVIS_COMMIT_RANGE \ + -e MJKEY \ + -e GITHUB_ACTIONS \ + -e CODECOV_TOKEN \ + $ci_env\ + --memory 6500m \ + --memory-swap 6500m \ + "${DOCKER_TAG}" pytest -v -m nightly + + + verify_envs_conda: + name: Verify Conda Environment Installation + runs-on: ubuntu-latest + needs: build_docker_container + if: github.event_name == 'schedule' + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Pull from cache (GitHub Package Registry) + run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Tag docker image + run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: Verify Conda + run: | + docker run \ + -e TRAVIS_COMMIT_RANGE \ + -e MJKEY \ + --memory 6500m \ + --memory-swap 6500m \ + "${DOCKER_TAG}" \ + /bin/bash -c \ + 'CONDA_ROOT=$HOME/miniconda \ + CONDA=${CONDA_ROOT}/bin/conda \ + GARAGE_BIN=${CONDA_ROOT}/envs/garage-ci/bin; \ + touch ${MJKEY_PATH} && \ + wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh && \ + bash miniconda.sh -b -p ${CONDA_ROOT} && \ + hash -r && \ + ${CONDA} config --set always_yes yes --set changeps1 no && \ + ${CONDA} install -c anaconda setuptools && \ + ${CONDA} update -q conda && \ + ${CONDA} init && \ + ${CONDA} info -a && \ + ${CONDA} create -n garage-ci python=3.5 pip -y && \ + ${GARAGE_BIN}/pip install --upgrade pip setuptools && \ + ${GARAGE_BIN}/pip install dist/garage.tar.gz[all,dev] && \ + ${GARAGE_BIN}/pylint --disable=all --enable=import-error garage' + + + verify_envs_pipenv: + name: Verify Pipenv Environment Installation + runs-on: ubuntu-latest + needs: build_docker_container + if: github.event_name == 'schedule' + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Login to GitHub Package Registry + run: echo ${{ secrets.CI_REGISTRY_TOKEN }} | docker login docker.pkg.github.com -u ${CI_USER} --password-stdin + - name: Pull from cache (GitHub Package Registry) + run: docker pull "docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG}" + - name: Tag docker image + run: docker tag docker.pkg.github.com/${OWNER}/${DOCKER_CACHE_REPO}/${DOCKER_TAG} ${DOCKER_TAG} + - name: Verify Pipenv + run: | + docker run \ + -e TRAVIS_COMMIT_RANGE \ + -e MJKEY \ + --memory 6500m \ + --memory-swap 6500m \ + "${DOCKER_TAG}" \ + /bin/bash -c \ + "export PATH=\$PATH_NO_VENV && \ + export VIRTUAL_ENV= && \ + export PIPENV_MAX_RETRIES=2 && \ + touch \${MJKEY_PATH} && \ + pip3 install --upgrade pip setuptools && \ + pip3 install pipenv && \ + pipenv --python=3.5 && \ + pipenv install dist/garage.tar.gz[all,dev] && \ + pipenv graph && \ + # pylint will verify all imports work + pipenv run pylint --disable=all --enable=import-error garage" + + + deploy_to_pypi: + name: Deploy to PyPI + runs-on: ubuntu-latest + needs: [normal_test, large_test, mujoco_test, mujoco_test_long] + if: startsWith(github.ref, 'refs/tags/v') + + steps: + - uses: actions/checkout@v2 +# with: +# ref: +# with: +# fetch-depth: 0 + - name: Set up Python 3.5 + uses: actions/setup-python@v1 + with: + python-version: 3.5 + - name: Update Version + run: echo ${GITHUB_REF##*/} > VERSION + - name: Update setuptools + run: pip install --upgrade setuptools + - name: Setup Distribution + run: >- + python setup.py sdist + - name: Deploy to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} + + + delete_docker_container: + name: Delete Docker Container + runs-on: ubuntu-latest + needs: [normal_test, large_test, mujoco_test, mujoco_test_long, nightly_test, verify_envs_conda, verify_envs_pipenv] + if: always() + + steps: + - uses: actions/delete-package-versions@v1 + with: + owner: ${{ env.OWNER }} + repo: ${{ env.DOCKER_CACHE_REPO }} + package-name: ${{ env.DOCKER_TAG }} + token: ${{ secrets.CI_REGISTRY_TOKEN }} diff --git a/docs/user/update_ci_for_release.md b/docs/user/update_ci_for_release.md new file mode 100644 index 0000000000..d9a7855618 --- /dev/null +++ b/docs/user/update_ci_for_release.md @@ -0,0 +1,28 @@ +# CI + +The CI must be updated whenever there is a new release + +### How to create new CI for release + +#### Make new scheduled CI for release branch +**1. create new CI file in `.github/workflows` named `ci-` in the master branch** + +**2. copy the workflow in the `ci-release-TEMPLATE` file over to the `ci-` file** + +**3. rename the `name` attribute at the top of the file to `CI `** + +**4. Fill in the checkout action placeholder, use `with: release-` for checkout action** + +**5. Uncomment the `schedule` trigger. It's also fine to delete the `pull-request` trigger, that will be handled in the next step** + +###backport CI to release branch** + +**1. create new CI file in `.github/workflows` named `ci-` in the master branch** + +**2. copy the workflow in the `ci-release-TEMPLATE` file over to the `ci-` file** + +**3. rename the `name` attribute at the top of the file to `CI `** + +**4. Fill in the checkout action placeholder, use `with: fetch-depth: 0` for checkout action** + +**5. When creating a release branch, delete all the branch's CI files and add the new ci file.**