Skip to content

Commit

Permalink
CI - more caching: community.crypto and some vault caching tweaks (#43)
Browse files Browse the repository at this point in the history
* more caching

* debug

* debug

* debug++

* debug+++

* debug++++

* $(debug++++)

* humbug

* Finalize
  • Loading branch information
briantist committed Dec 29, 2020
1 parent d7be7b3 commit a135ea0
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions .github/workflows/ansible-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ jobs:
with:
python-version: 3.8

- name: Cache vault binaries
id: cache
- name: Cache for vault binaries
id: cache-vault
uses: actions/cache@v2
with:
path: ${{ env.LOOKUP_HASHI_VAULT_BIN }}
key: ${{ runner.os }}-vault${{ matrix.vault }}-${{ hashFiles(format('{0}/**', env.LOOKUP_HASHI_VAULT_BIN)) }} # future: include version/arch when configurable
key: ${{ runner.os }}-vault${{ matrix.vault }} # future: include version/arch when configurable

# removing .gitignore lets the files in those dirs be sent to the container via ansible-test
# the files/bin dir will contain the vault binary downloaded a few steps later
# the files/bin dir will contain the vault binary downloaded a few steps later (or retrieved from cache)
# the vars/ dir will be used to write a file overriding role defaults (for Vault version)
- name: Prepare for Vault version and caching
run: |
Expand All @@ -137,12 +137,32 @@ jobs:
- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check

#TODO: remove dependency on community.crypto
- name: Find the latest version of community.crypto
run: |
# credit to https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c#gistcomment-3294173
cclu=$(curl -fs -o/dev/null -w %{redirect_url} https://github.com/ansible-collections/community.crypto/releases/latest)
echo "CC_LATEST=$(basename ${cclu})" >> $GITHUB_ENV
- name: Cache for community.crypto
id: cache-cc
uses: actions/cache@v2
with:
path: ansible_collections/community/crypto
key: collection-community.crypto-${{ env.CC_LATEST }}

- name: Install collection dependencies
run: ansible-galaxy collection install community.crypto -p .
if: steps.cache-cc.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: ansible-collections/community.crypto
ref: refs/tags/${{ env.CC_LATEST }}
path: ansible_collections/community/crypto

# this will populate files/bin with the selected vault version binary
- name: Pre-download Vault
if: steps.cache.outputs.cache-hit != 'true'
if: steps.cache-vault.outputs.cache-hit != 'true'
env:
ANSIBLE_ROLES_PATH: ../
working-directory: ${{ env.LOOKUP_HASHI_VAULT_PATH }}/playbooks
Expand Down

0 comments on commit a135ea0

Please sign in to comment.