From 860eb11ef3063aa243a280116175e1ed5c35d6fe Mon Sep 17 00:00:00 2001 From: Ben Nibbelink Date: Sun, 12 Nov 2023 08:34:19 -0600 Subject: [PATCH] add Dockerfile and workflows --- .github/workflows/build_test.yml | 58 ++++++++++++++++++++++ .github/workflows/build_test_publish.yml | 63 ++++++++++++++++++++++++ docker/Dockerfile | 16 ++++++ 3 files changed, 137 insertions(+) create mode 100644 .github/workflows/build_test.yml create mode 100644 .github/workflows/build_test_publish.yml create mode 100644 docker/Dockerfile diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml new file mode 100644 index 0000000000..f489dac0f0 --- /dev/null +++ b/.github/workflows/build_test.yml @@ -0,0 +1,58 @@ +name: Build/Test for PR and collaborator push + +on: + # allows us to run workflows manually + workflow_dispatch: + pull_request: + paths-ignore: + - '.github/workflows/build_test_publish.yml' + - 'docker/**' + - 'doc/**' + push: + paths-ignore: + - '.github/workflows/build_test_publish.yml' + - 'docker/**' + - 'doc/**' + +jobs: + build-and-test: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + ubuntu_versions : [ + 20.04, + 22.04, + ] + pkg_mgr : [ + apt, + conda, + ] + cyclus_tag: [ + latest, + ] + + container: + image: ghcr.io/cyclus/cyclus_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cyclus:${{matrix.cyclus_tag}} + + steps: + - name: Checkout Cycamore + uses: actions/checkout@v3 + + - name: Change Home + run: | + echo "HOME=/root" >> "$GITHUB_ENV" + + - name: Build Cycamore + run: | + python install.py --prefix=/root/.local -j 2 --build-type=Release --core-version 99999.99999 + + - name: Cycamore Unit Tests + run: | + cycamore_unit_tests + + - name: Cycamore Python Tests + run: | + cd tests && python -m pytest diff --git a/.github/workflows/build_test_publish.yml b/.github/workflows/build_test_publish.yml new file mode 100644 index 0000000000..86a79d9fad --- /dev/null +++ b/.github/workflows/build_test_publish.yml @@ -0,0 +1,63 @@ +name: Build and Test Dependency Images + +on: + # allows us to run workflows manually + workflow_dispatch: + pull_request: + paths: + - '.github/workflows/build_test_publish.yml' + - 'docker/**' + push: + branches: + - main + paths: + - '.github/workflows/build_test_publish.yml' + - 'docker/**' + +jobs: + build-dependency-and-test-img: + runs-on: ubuntu-latest + + strategy: + matrix: + ubuntu_versions : [ + 20.04, + 22.04, + ] + pkg_mgr : [ + apt, + conda, + ] + + name: Installing Dependencies, Building cyclus and running tests + steps: + - name: default environment + run: | + echo "tag-latest-on-default=false" >> "$GITHUB_ENV" + + - name: condition on trigger parameters + if: ${{ github.repository_owner == 'cyclus' && github.ref == 'refs/heads/main' }} + run: | + echo "tag-latest-on-default=true" >> "$GITHUB_ENV" + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Installing Dependencies in Docker image + uses: firehed/multistage-docker-build-action@v1 + with: + repository: ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }} + stages: cycamore + server-stage: cycamore-test + quiet: false + parallel: true + tag-latest-on-default: ${{ env.tag-latest-on-default }} + dockerfile: docker/Dockerfile + build-args: pkg_mgr=${{ matrix.pkg_mgr }}, ubuntu_version=${{ matrix.ubuntu_versions }} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000..8d2d339526 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,16 @@ +ARG pkg_mgr=apt +ARG ubuntu_version=22.04 + +FROM ghcr.io/cyclus/cyclus_${ubuntu_version}_${pkg_mgr}/cyclus as cycamore +ARG make_cores=2 + +COPY . /cycamore +WORKDIR /cycamore + +RUN python install.py -j ${make_cores} --build-type=Release --core-version 99999.99999 + +FROM cycamore as cycamore-test +RUN cycamore_unit_tests + +FROM cycamore as cycamore-pytest +RUN cd tests && python -m pytest