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 #573

Merged
merged 28 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7ae78e6
update cycamore workflows to reflect cyclus PR
bennibbelink Jan 29, 2024
d3d4600
add permissions
bennibbelink Jan 29, 2024
11fa270
use new checkout version
bennibbelink Jan 29, 2024
d3b9b4c
use new login-action version
bennibbelink Jan 29, 2024
b694c05
update another version number
bennibbelink Jan 29, 2024
953078e
add downstream testing
bennibbelink Jan 29, 2024
50ca712
soft fail on cycamore fail
bennibbelink Jan 29, 2024
51c2df4
add release workflow
bennibbelink Jan 29, 2024
a6fbe92
edit commnet
bennibbelink Jan 29, 2024
eac07da
fix needs typo
bennibbelink Jan 29, 2024
7fa7d27
add stable tag to matrix
bennibbelink Jan 29, 2024
64ef87c
update changelog
bennibbelink Jan 29, 2024
0857eaa
allow pr write permission
bennibbelink Jan 29, 2024
64fe3ca
renamed workflows to be more transparent
bennibbelink Jan 29, 2024
be99cd2
rename job
bennibbelink Jan 29, 2024
d84c7a6
remove preliminary build step in publishing workflows
bennibbelink Jan 29, 2024
8017fac
forgot to push image-cache for cycamore
bennibbelink Feb 5, 2024
c2d6652
specify token since it is different repo
bennibbelink Feb 5, 2024
7668b2c
forgot to specify key
bennibbelink Feb 5, 2024
4d9ac03
reorder login step
bennibbelink Feb 5, 2024
9c040db
logout: false
bennibbelink Feb 5, 2024
4983b73
remove bad attempts at permissioning
bennibbelink Feb 5, 2024
40a99da
update release name references
bennibbelink Feb 7, 2024
09435cd
publish cymetric:latest on cycamore push to main
bennibbelink Feb 8, 2024
2808739
change trigger ignores
bennibbelink Feb 8, 2024
6060c0e
use well-defined directory to checkout cymetric
bennibbelink Feb 9, 2024
b709142
change trigger for release
bennibbelink Feb 10, 2024
293b758
remove ref parameters from cymetric checkout
bennibbelink Feb 11, 2024
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
88 changes: 70 additions & 18 deletions .github/workflows/build_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@ 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
Expand All @@ -34,24 +37,73 @@ jobs:
]
cyclus_tag: [
latest,
stable,
]

container:
image: ghcr.io/cyclus/cyclus_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cyclus:${{matrix.cyclus_tag}}

steps:

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

- 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: Checkout Cycamore
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Build Cycamore
run: |
python install.py --prefix=/root/.local --cyclus-root=/root/.local -j 2 --build-type=Release --core-version 99999.99999
id: build-cycamore
continue-on-error: true
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
cache-from: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max
tags: ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-image-cache
push: true
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cyclus_tag=${{ matrix.cyclus_tag }}

- name: Checkout Cymetric
if: ${{ github.event_name == 'pull_request' && steps.build-cycamore.outcome == 'success' }}
uses: actions/checkout@v4
with:
repository: cyclus/cymetric
path: ${{ github.workspace }}/cymetric

- name: Cycamore Unit Tests
run: |
cycamore_unit_tests
- name: Build and Test Cymetric
if: ${{ github.event_name == 'pull_request' && steps.build-cycamore.outcome == 'success' }}
id: build-cymetric
continue-on-error: true
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}/cymetric
file: ${{ github.workspace }}/cymetric/docker/Dockerfile
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
tags: ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-image-cache
push: true
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cycamore_tag=ci-image-cache@${{ steps.build-cycamore.outputs.digest }}

- name: Cycamore Python Tests
run: |
export PYTHONPATH=$(find /root/.local/lib -type d -name 'python*.*' -print -quit)/site-packages
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.cyclus_tag }}
message: |
## Build statuses using cyclus_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}:${{ matrix.cyclus_tag }}
- Cycamore: ${{steps.build-cycamore.outcome == 'success' && '*Success* :white_check_mark:' ||
steps.build-cycamore.outcome == 'failure' && '**Failure** :x:' ||
'**Skipped due to upstream failure** :warning:'}}
- 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
89 changes: 89 additions & 0 deletions .github/workflows/publish_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Publish Latest Cycamore

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-dependency-and-test-img:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

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

name: Build, Test, Publish
steps:
- name: Tag as ci-image-cache
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: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- 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: Build and Test Cycamore
id: build-cycamore
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max
file: docker/Dockerfile
push: true
tags: ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.tag }}
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cyclus_tag=latest

- name: Checkout Cymetric
uses: actions/checkout@v4
with:
repository: cyclus/cymetric
path: ${{ github.workspace }}/cymetric

- name: Build and Test Cymetric
continue-on-error: true
uses: docker/build-push-action@v5
with:
context: ${{ github.workspace }}/cymetric
file: ${{ github.workspace }}/cymetric/docker/Dockerfile
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
tags: ghcr.io/cyclus/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:${{ env.tag }}
push: true
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cycamore_tag=${{ env.tag }}@${{ steps.build-cycamore.outputs.digest }}

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 Cycamore

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: Build, 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 Cycamore
uses: actions/checkout@v4

- name: Build, Test, and Push Cycamore
uses: docker/build-push-action@v5
with:
cache-from: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max
file: docker/Dockerfile
push: true
tags: |
ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.version_tag }}
ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:${{ env.stable_tag }}
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cyclus_tag=stable
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ cycamore Change Log
.. current developments
**Added:**

* GitHub workflows for building/testing on a PR and push to `main` (#549, #564)
* GitHub workflow for publishing images on release (#573)
* GitHub workflows for building/testing on a PR and push to `main` (#549, #564, #573)
* Add functionality for random behavior on the size (#550) and frequency (#565) of a sink
* GitHub workflow to check that the CHANGELOG has been updated (#562)
* Added inventory policies to Storage through the material buy policy (#574)
Expand Down
9 changes: 5 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
ARG pkg_mgr=apt
ARG ubuntu_version=22.04
ARG cyclus_tag=stable

FROM ghcr.io/cyclus/cyclus_${ubuntu_version}_${pkg_mgr}/cyclus as cycamore
FROM ghcr.io/cyclus/cyclus_${ubuntu_version}_${pkg_mgr}/cyclus:${cyclus_tag} as cycamore
ARG make_cores=2

COPY . /cycamore
WORKDIR /cycamore

RUN python install.py -j ${make_cores} --build-type=Release --core-version 99999.99999
RUN python install.py -j ${make_cores} --build-type=Release --core-version 999999.999999

FROM cycamore as cycamore-test
RUN cycamore_unit_tests

FROM cycamore as cycamore-pytest
RUN cd tests && python -m pytest
FROM cycamore-test as cycamore-pytest
RUN cd tests && python -m pytest
Loading