-
Notifications
You must be signed in to change notification settings - Fork 1
149 lines (125 loc) · 5.31 KB
/
test-action.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
138
139
140
141
142
143
144
145
146
147
148
149
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch: {}
defaults:
run:
shell: bash
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
prepopulate-cache:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Information on prepopulating cache
run: |
echo "This makes sure the cache has something in it before running the cache-hit test."
echo "The same key is used in the prepopulate-cache job as in the cache-hit job."
- name: Cache Container Images
id: cache-container-images
uses: ./
with:
runtime: podman
prefix-key: 'podman-cache-hit ${{ github.run_id }}'
images: |
selenium/node-chrome:4.1.2-20220130
selenium/hub:4.1.2-20220130
cache-hit-test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: prepopulate-cache
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Information on cache-hit test
run: |
echo "Attempt to pull images using same key used in prepopulate-cache."
echo "Since something is in the cache, we expect this test to pass with a cache HIT."
- name: Cache Container Images
id: cache-container-images
# In your project you replace local version "./" with following
# uses: jamesmortensen/cache-container-images-action@master
uses: ./
with:
runtime: podman
prefix-key: 'podman-cache-hit ${{ github.run_id }}'
images: |
selenium/node-chrome:4.1.2-20220130
selenium/hub:4.1.2-20220130
- name: Check that we can install to .local without permission issues
run: |
ls -ltrSha ~/.local
echo "Attempting to install podman-compose. If it installs successfully, then permissions are ok"
pip3 install podman-compose
- name: Pass test only if there is a cache hit
if: ${{ steps.cache-container-images.outputs.cache-hit == 'true' }}
shell: bash
run: echo "Container images are found in the cache. Test passes!"
- name: Fail test if there is a cache miss
if: ${{ steps.cache-container-images.outputs.cache-hit != 'true' }}
shell: bash
run: |
echo "Container images are not found in the cache! Test FAILS!"
exit 1
- name: Start and stop container with podman
run: |
echo Before running podman run...
echo Run podman run...
podman run --rm -d --cidfile cid-node selenium/node-chrome:4.1.2-20220130
podman run --rm -d --cidfile cid-hub selenium/hub:4.1.2-20220130
echo After running podman run...
podman stop --cidfile cid-node
podman stop --cidfile cid-hub
cache-miss-test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
- name: Information on cache-miss test
run: |
echo "Attempt to pull images using randomized key."
echo "Nothing should be in the cache, we expect this test to pass with a cache MISS."
- name: Cache Container Images
id: cache-container-images
# In your project you replace local version "./" with following
# uses: jamesmortensen/cache-container-images-action@master
uses: ./
with:
prefix-key: 'podman-cache-miss ${{ github.run_id }}'
images: |
selenium/node-chrome:latest
selenium/hub:latest
- name: Check that we can install to .local without permission issues
run: |
ls -ltrSha ~/.local
echo "Attempting to install podman-compose. If it installs successfully, then permissions are ok"
pip3 install podman-compose
- name: Fail test if there is a cache hit
if: ${{ steps.cache-container-images.outputs.cache-hit == 'true' }}
shell: bash
run: |
echo "Container images are found in the cache! Test FAILS!"
exit 1
- name: Pass test only if there is a cache miss
if: ${{ steps.cache-container-images.outputs.cache-hit != 'true' }}
shell: bash
run: echo "Container images are not found in the cache. Test passes!"
- name: Start and stop container with podman
run: |
echo Before running podman run...
echo Run podman run...
podman run --rm -d --cidfile cid-node selenium/node-chrome:latest
podman run --rm -d --cidfile cid-hub selenium/hub:latest
echo After running podman run...
podman stop --cidfile cid-node
podman stop --cidfile cid-hub