Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI refactoring #190

Merged
merged 20 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 42 additions & 26 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ on:
workflow_dispatch:
pull_request:
paths-ignore:
- '.github/workflows/build_test_publish.yml'
- 'docker/**'
- '.github/workflows/publish_latest.yml'
- '.github/workflows/publish_release.yml'
- 'doc/**'
- 'CHANGELOG.rst'
push:
paths-ignore:
- '.github/workflows/build_test_publish.yml'
- 'docker/**'
- '.github/workflows/publish_latest.yml'
- '.github/workflows/publish_release.yml'
- 'doc/**'
- 'CHANGELOG.rst'

jobs:
build-and-test:

runs-on: ubuntu-latest

permissions:
contents: read
packages: write
pull-requests: write

strategy:
fail-fast: false
matrix:
Expand All @@ -34,30 +37,43 @@ jobs:
]
cycamore_tag: [
latest,
stable,
]

container:
image: ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{matrix.cycamore_tag}}

steps:
- name: Checkout Cymetric
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Cymetric Apt Dependencies
if: matrix.pkg_mgr == 'apt'
run: |
apt update --fix-missing && apt install -y python3-pip python3-pytest

- name: Install Cymetric Conda Dependencies
if: matrix.pkg_mgr == 'conda'
run: |
mamba install -y pip pytest
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Cymetric
run: |
python -m pip install --target $(python -m site --user-site) .
- name: Build and Test Cymetric
id: build-cymetric
continue-on-error: true
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache,mode=max
file: docker/Dockerfile
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cycamore_tag=${{ matrix.cycamore_tag }}

- name: Cymetric Tests
run: |
export PYTHONPATH=$(find /root/.local/lib -type d -name 'cyclus-*-*.egg' -print -quit)
cd tests && python -m pytest
- name: PR Comment
if: ${{ github.event_name == 'pull_request' }}
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: ${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}_${{ matrix.cycamore_tag }}
message: |
## Build statuses using cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}:${{ matrix.cycamore_tag }}
- Cymetric: ${{steps.build-cymetric.outcome == 'success' && '*Success* :white_check_mark:' ||
steps.build-cymetric.outcome == 'failure' && '**Failure** :x:' ||
'**Skipped due to upstream failure** :warning:'}}
60 changes: 0 additions & 60 deletions .github/workflows/build_test_publish.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/changelog_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
git --version

- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/publish_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Publish Latest Cymetric

on:
# allows us to run workflows manually
workflow_dispatch:
pull_request:
paths:
- '.github/workflows/publish_latest.yml'
gonuke marked this conversation as resolved.
Show resolved Hide resolved
push:
branches:
- main

jobs:
build-cymetric-and-push:
runs-on: ubuntu-latest

strategy:
matrix:
ubuntu_versions : [
20.04,
22.04,
]
pkg_mgr : [
apt,
conda,
]

name: Build, Test, Publish
steps:
- name: Tag as ci-image-cache by default
run: |
echo "tag=ci-image-cache" >> "$GITHUB_ENV"

- name: Tag as latest
if: ${{ github.repository_owner == 'cyclus' && github.ref == 'refs/heads/main' }}
run: |
echo "tag=latest" >> "$GITHUB_ENV"

- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and Test Cymetric
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache,mode=max
file: docker/Dockerfile
push: true
tags: ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:${{ env.tag }}
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cycamore_tag=latest
65 changes: 65 additions & 0 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Publish Stable Cymetric

on:
release:
types: [released]

jobs:
build-and-test-for-release:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

strategy:
fail-fast: false
matrix:
ubuntu_versions : [
20.04,
22.04,
]
pkg_mgr : [
apt,
conda
]

name: Building, Test, Publish
steps:
- name: Tag as ci-image-cache
run: |
echo "version_tag=ci-image-cache" >> "$GITHUB_ENV"
echo "stable_tag=ci-image-cache" >> "$GITHUB_ENV"

- name: Tag as stable
if: ${{ github.repository_owner == 'cyclus' }}
run: |
echo "version_tag=${{ github.ref_name }}" >> "$GITHUB_ENV"
echo "stable_tag=stable" >> "$GITHUB_ENV"

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Checkout Cymetric
uses: actions/checkout@v4

- name: Build and Test Cymetric
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache,mode=max
file: docker/Dockerfile
push: true
tags: |
ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:${{ env.version_tag }}
ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:${{ env.stable_tag }}
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cycamore_tag=stable
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cymetric Change Log

.. current developments
**Added:**
* GitHub workflows for CI (#188)
* GitHub workflows for CI (#188, #190)

**Changed**
* Converted test suite from nose to pytest (#188)
Expand Down
10 changes: 2 additions & 8 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
ARG pkg_mgr=apt
ARG ubuntu_version=22.04
ARG cycamore_tag=stable

FROM ghcr.io/cyclus/cycamore_${ubuntu_version}_${pkg_mgr}/cycamore as cycamore
FROM ghcr.io/cyclus/cycamore_${ubuntu_version}_${pkg_mgr}/cycamore:${cycamore_tag} as cymetric

FROM cycamore as apt-deps
RUN apt update --fix-missing && apt install -y python3-pip python3-pytest

FROM cycamore as conda-deps
RUN mamba install -y pip pytest

FROM ${pkg_mgr}-deps as cymetric
COPY . /cymetric
WORKDIR /cymetric
RUN python -m pip install --target $(python -m site --user-site) .
Expand Down
Loading