diff --git a/.github/actions/with-docker/Dockerfile b/.github/actions/with-docker/Dockerfile new file mode 100644 index 0000000..4b9435a --- /dev/null +++ b/.github/actions/with-docker/Dockerfile @@ -0,0 +1,22 @@ +ARG K_VERSION +FROM runtimeverificationinc/kframework-k:ubuntu-jammy-${K_VERSION} + +ARG PYTHON_VERSION=3.10 + +RUN apt-get -y update \ + && apt-get -y install \ + graphviz \ + python${PYTHON_VERSION} \ + python${PYTHON_VERSION}-dev \ + && apt-get -y clean + +ARG USER_ID=9876 +ARG GROUP_ID=9876 +RUN groupadd -g ${GROUP_ID} user \ + && useradd -m -u ${USER_ID} -s /bin/bash -g user user + +USER user +WORKDIR /home/user + +ENV PATH=/home/user/.local/bin:${PATH} +RUN curl -sSL https://install.python-poetry.org | python3 - diff --git a/.github/actions/with-docker/action.yml b/.github/actions/with-docker/action.yml new file mode 100644 index 0000000..c44bb1a --- /dev/null +++ b/.github/actions/with-docker/action.yml @@ -0,0 +1,36 @@ +name: 'With Docker' +description: 'Run a given stage with Docker Image' +inputs: + container-name: + description: 'Docker container name to use' + type: string + required: true +runs: + using: 'composite' + steps: + - name: 'Set up Docker' + shell: bash {0} + run: | + set -euxo pipefail + + CONTAINER_NAME=${{ inputs.container-name }} + TAG=runtimeverificationinc/${CONTAINER_NAME} + K_VERSION=$(cat deps/k_release) + + docker build . \ + --file .github/actions/with-docker/Dockerfile \ + --tag ${TAG} \ + --build-arg K_VERSION=${K_VERSION} + + docker run \ + --name ${CONTAINER_NAME} \ + --rm \ + --interactive \ + --tty \ + --detach \ + --user root \ + --workdir /home/user \ + ${TAG} + + docker cp . ${CONTAINER_NAME}:/home/user + docker exec ${CONTAINER_NAME} chown -R user:user /home/user diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 46bee75..72a3edc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,3 +31,42 @@ jobs: git add --update && git commit --message "Set Version: ${new_version}" || true - name: 'Push updates' run: git push origin HEAD:${GITHUB_HEAD_REF} + + code-quality-checks: + needs: version-bump + name: 'Code Quality Checks' + runs-on: [self-hosted, linux, flyweight] + steps: + - name: 'Check out code' + uses: actions/checkout@v3 + - name: 'Run code quality checks' + run: make check + - name: 'Run pyupgrade' + run: make pyupgrade + - name: 'Run unit tests' + run: make test-unit + + integration-tests: + needs: code-quality-checks + name: 'Integration Tests' + runs-on: [self-hosted, linux, normal] + env: + CONTAINER: ksoroban-integration-${{ github.sha }} + steps: + - name: 'Check out code' + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: 'Set up Docker' + uses: ./.github/actions/with-docker + with: + container-name: ${CONTAINER} + - name: 'Build ksoroban' + run: docker exec --user user ${CONTAINER} poetry install + - name: 'Build semantics' + run: docker exec --user user ${CONTAINER} make kdist-build + - name: 'Run integration tests' + run: docker exec --user user ${CONTAINER} make test-integration + - name: 'Tear down Docker' + if: always() + run: docker stop --time=0 ${CONTAINER}