Merge pull request #3 from Borda/action/Checkout #16
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |