-
Notifications
You must be signed in to change notification settings - Fork 40
137 lines (120 loc) · 5.23 KB
/
build_test.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Build/Test for PR and collaborator push
on:
# allows us to run workflows manually
workflow_dispatch:
pull_request:
paths-ignore:
- '.github/workflows/publish_latest.yml'
- '.github/workflows/publish_release.yml'
- 'doc/**'
- 'CHANGELOG.rst'
push:
paths-ignore:
- '.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
strategy:
fail-fast: false
matrix:
ubuntu_versions : [
20.04,
22.04,
]
pkg_mgr : [
apt,
conda,
]
cyclus_tag: [
latest,
stable,
]
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@v4
- name: Build Cycamore
id: build-cycamore
continue-on-error: true
uses: docker/build-push-action@v5
with:
file: docker/Dockerfile
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-layer-cache,mode=max
# tags: ghcr.io/${{ github.repository_owner }}/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-image-cache
# push: true
outputs: type=image,name=cycamore:ci-image-cache
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: 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/${{ github.repository_owner }}/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/cymetric_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cymetric:ci-layer-cache,mode=max
build-args: |
pkg_mgr=${{ matrix.pkg_mgr }}
ubuntu_version=${{ matrix.ubuntu_versions }}
cycamore_tag=ci-image-cache
build-contexts: |
ghcr.io/cyclus/cycamore_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cycamore:ci-image-cache=docker-image://cycamore:ci-image-cache@${{ steps.build-cycamore.outputs.digest }}
- name: Export Environment Variables
if: github.event_name == 'pull_request'
run: |
echo "CYCAMORE_BUILD_STATUS=${{steps.build-cycamore.outcome == 'success' && '**Success** :white_check_mark:' ||
steps.build-cycamore.outcome == 'failure' && '**Failure** :x:' ||
'**Skipped due to upstream failure** :warning:'}}" >> "$GITHUB_ENV"
echo "CYMETRIC_BUILD_STATUS=${{steps.build-cymetric.outcome == 'success' && '**Success** :white_check_mark:' ||
steps.build-cymetric.outcome == 'failure' && '**Failure** :x:' ||
'**Skipped due to upstream failure** :warning:'}}" >> "$GITHUB_ENV"
echo "ARTIFACT_NAME=${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}_${{ matrix.cyclus_tag }}" >> "$GITHUB_ENV"
- name: Construct Artifact
if: github.event_name == 'pull_request'
run: |
echo "
##### Build \`FROM cyclus_${{ matrix.ubuntu_versions }}_${{ matrix.pkg_mgr }}/cyclus:${{ matrix.cyclus_tag }}\`
- Cycamore: ${{ env.CYCAMORE_BUILD_STATUS }}
- Cymetric: ${{ env.CYMETRIC_BUILD_STATUS }}" > ${{ env.ARTIFACT_NAME }}.txt
- name: Upload Artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_NAME }}.txt
upload-pr-number:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Save PR number to file
run: |
echo "${{ github.event.number }}" > pr_number
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number