forked from TreeMaker/TreeMaker
-
Notifications
You must be signed in to change notification settings - Fork 1
127 lines (120 loc) · 8.9 KB
/
Copy pathdockerimage.yml
File metadata and controls
127 lines (120 loc) · 8.9 KB
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
name: Docker Image CI
on:
workflow_dispatch:
push:
branches: [ Run2_UL ]
pull_request:
branches: [ Run2_UL ]
env:
current_branch: $(echo ${{ github.ref }} | sed -E 's|refs/[a-zA-Z]+/||')
current_user: ${{ github.actor }}
cmssw_ver: CMSSW_10_6_29_patch1
jobs:
# The 'build' job runs a Docker container with CVMFS mounted inside in order to checkout a CMSSW release and install the TreeMaker software
# The CVMFS cache is then cleared to shrink the image
build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip build]')"
steps:
- name: Reset User on Push
if: github.event_name == 'push'
run: echo "current_user=$(echo ${{ github.repository }} | sed -E 's|/.*||')" >> $GITHUB_ENV
- name: Reset User on Pull Request
if: github.event_name == 'pull_request'
run: echo "current_user=${{ github.event.pull_request.head.repo.owner.login }}" >> $GITHUB_ENV
- name: Reset Branch on Pull Request
if: github.event_name == 'pull_request'
run: echo "current_branch=${{ github.head_ref }}" >> $GITHUB_ENV
- name: Look at key environment variables
run: echo -e "GITHUB_REF=${{ github.ref }}\nGITHUB_HEAD_REF=${{ github.head_ref }}\nGITHUB_BASE_REF=${{ github.base_ref }}\nGITHUB_ACTOR=${{ github.actor }}\nGITHUB_REPOSITORY=${{ github.repository }}\nGITHUB_SHA=${{ github.sha }}\nUSER=${{ env.current_user }}\nBANCH=${{ env.current_branch }}"
- name: Take a look around
run: pwd && ls -alh
- name: Run a CVMFS Docker image and run the setup script
env:
build_image: aperloff/cms-cvmfs-docker:light
docker_options: -t -P --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined -e CVMFS_MOUNTS="cms.cern.ch" --name treemaker --entrypoint "/bin/bash"
run: docker run ${{ env.docker_options }} ${{ env.build_image }} -c "/run.sh -c \"wget https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/setup.sh && chmod +x setup.sh && ./setup.sh -a https -f ${{ env.current_user }} -b ${{ env.current_branch }} -B -j 2\" && cvmfs_config wipecache"
- name: Commit the changes
run: docker commit -c 'ENTRYPOINT ["/run.sh"]' -c 'CMD []' treemaker treemaker/treemaker:${{ env.current_branch }}-latest
- name: Log into registry
if: "github.event_name != 'pull_request' && !contains(github.event.head_commit.message, '[skip publish]') && env.current_user == 'TreeMaker'"
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Publish the new docker image
if: "github.event_name != 'pull_request' && !contains(github.event.head_commit.message, '[skip publish]') && env.current_user == 'TreeMaker'"
run: docker push treemaker/treemaker:${{ env.current_branch }}-latest
# Run the integration test within the 'build' job only if this is a pull_request initiated build
# This is because the 'integration-test' job can't run if the 'build' job image isn't pushed to a registry,
# which can't happen because secrets aren't available within externally initiated pull_requests.
- name: Run the container and perform an integration test
if: github.event_name == 'pull_request'
env:
download_url: https://cernbox.cern.ch/remote.php/dav/public-files/3xHyo11H3fAgCHZ/store.mc.RunIISummer20UL16MiniAODv2.QCD_HT2000toInf_TuneCP5_PSWeights_13TeV-madgraphMLM-pythia8.MINIAODSIM.106X_mcRun2_asymptotic_v17-v1.120000.0605C02A-A789-C548-8D73-9B7D0A4D5561_100evt.root
file_name: store.mc.RunIISummer20UL16MiniAODv2.QCD_HT2000toInf_TuneCP5_PSWeights_13TeV-madgraphMLM-pythia8.MINIAODSIM.106X_mcRun2_asymptotic_v17-v1.120000.0605C02A-A789-C548-8D73-9B7D0A4D5561_100evt.root
era: Summer20UL16
output_name: Summer20UL16.QCD_HT2000toInf_TuneCP5_PSWeights_13TeV-madgraphMLM-pythia8
integration_test_image: treemaker/treemaker:${{ env.current_branch }}-latest
docker_options: -t -P --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined -e CVMFS_MOUNTS="cms.cern.ch" --name treemaker-integration
run: docker run ${{ env.docker_options }} ${{ env.integration_test_image }} -- -i -c "cd ${{ env.cmssw_ver }}/src/ && cmsenv && cd TreeMaker/Production/test/ && wget ${{ env.download_url }} -O ${{ env.file_name }} && python unitTest.py test=0 scenario=${{ env.era }} dataset=file:${{ env.file_name }} name=${{ env.output_name }} run=True fork=False log=False clean=99"
# The 'integration-test' job opens the previous 'build' image, pulled from the registry, to:
# 1. test that the image was successfully uploaded to the registry
# 2. test that the image can be run
# 3. run an integration test
# 4. cache the CVMFS files necessary to run an integration test
# 5. Save the image with the intact cache and upload it to the registry
integration-test:
runs-on: ubuntu-latest
needs: [build]
if: "!contains(github.event.head_commit.message, '[skip test]') && !contains(github.event.head_commit.message, '[skip publish]') && github.event_name != 'pull_request'"
steps:
- name: Reset User on Push
if: github.event_name == 'push'
run: echo "current_user=$(echo ${{ github.repository }} | sed -E 's|/.*||')" >> $GITHUB_ENV
- name: Run the container and perform an integration test
env:
download_url: https://cernbox.cern.ch/remote.php/dav/public-files/3xHyo11H3fAgCHZ/store.mc.RunIISummer20UL16MiniAODv2.QCD_HT2000toInf_TuneCP5_PSWeights_13TeV-madgraphMLM-pythia8.MINIAODSIM.106X_mcRun2_asymptotic_v17-v1.120000.0605C02A-A789-C548-8D73-9B7D0A4D5561_100evt.root
file_name: store.mc.RunIISummer20UL16MiniAODv2.QCD_HT2000toInf_TuneCP5_PSWeights_13TeV-madgraphMLM-pythia8.MINIAODSIM.106X_mcRun2_asymptotic_v17-v1.120000.0605C02A-A789-C548-8D73-9B7D0A4D5561_100evt.root
era: Summer20UL16
output_name: Summer20UL16.QCD_HT2000toInf_TuneCP5_PSWeights_13TeV-madgraphMLM-pythia8
integration_test_image: treemaker/treemaker:${{ env.current_branch }}-latest
docker_options: -t -P --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined -e CVMFS_MOUNTS="cms.cern.ch" --name treemaker
run: docker run ${{ env.docker_options }} ${{ env.integration_test_image }} -- -i -c "pushd . && cd ${{ env.cmssw_ver }}/src/ && cmsenv && cd TreeMaker/Production/test/ && wget ${{ env.download_url }} -O ${{ env.file_name }} && python unitTest.py test=0 scenario=${{ env.era }} dataset=file:${{ env.file_name }} name=${{ env.output_name }} run=True fork=False log=False clean=99 && rm ${{ env.file_name }} && popd"
- name: Commit the changes
run: docker commit -c 'ENTRYPOINT ["/run.sh"]' -c 'CMD []' treemaker treemaker/treemaker:${{ env.current_branch }}-cache
- name: Log into registry
if: env.current_user == 'TreeMaker'
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
- name: Publish the new docker image
if: env.current_user == 'TreeMaker'
run: docker push treemaker/treemaker:${{ env.current_branch }}-cache
build-standalone:
name: Mirror, run GitLab CI, produce Standalone Docker image
runs-on: ubuntu-latest
needs: [build]
if: "!contains(github.event.head_commit.message, '[skip service-x]') && !contains(github.event.head_commit.message, '[skip publish]') && github.event_name != 'pull_request'"
steps:
- name: Redefine branch on push
if: github.event_name == 'push'
run: |
echo "current_branch=$(echo ${{ github.ref }} | sed -E 's|refs/[a-zA-Z]+/||')" >> $GITHUB_ENV
- name: Reset user on push
if: github.event_name == 'push'
run: echo "current_user=$(echo ${{ github.repository }} | sed -E 's|/.*||')" >> $GITHUB_ENV
- name: Look at key environment variables
run: echo -e "GITHUB_REF=${{ github.ref }}\nGITHUB_HEAD_REF=${{ github.head_ref }}\nGITHUB_BASE_REF=${{ github.base_ref }}\nGITHUB_ACTOR=${{ github.actor }}\nGITHUB_REPOSITORY=${{ github.repository }}\nGITHUB_SHA=${{ github.sha }}\nUSER=${{ env.current_user }}\nBANCH=${{ env.current_branch }}\nTIME=${{ steps.current-time.outputs.formattedTime }}"
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v1
- name: Mirror + trigger CI
uses: aperloff/gitlab-mirror-and-ci-action@master
with:
args: "https://gitlab.cern.ch/treemaker/TreeMaker"
env:
GITLAB_HOSTNAME: "gitlab.cern.ch"
GITLAB_USERNAME: ${{ secrets.GITLAB_USERNAME }}
GITLAB_PASSWORD: ${{ secrets.GITLAB_PASSWORD }} # Generate here: https://gitlab.cern.ch/-/profile/personal_access_tokens and add to GitHub secrets
GITLAB_PROJECT_ID: "90027"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # https://help.github.com/en/articles/virtual-environments-for-github-actions#github_token-secret and add to GitHub secrets
CHECKOUT_BRANCH: ${{ env.current_branch }}
POLL_TIMEOUT: 60