chore(testutil): refactor #34
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
name: Pro Tests | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- '**.md' | |
schedule: | |
- cron: "0 0 */2 * *" | |
workflow_run: | |
workflows: ["CLA check"] | |
types: | |
- completed | |
jobs: | |
real-archive-tests: | |
name: Real Archive Tests | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
# Do not change to newer releases as "fips" may not be available there. | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v3 | |
with: | |
go-version-file: 'go.mod' | |
- name: Run real archive tests | |
env: | |
PRO_TOKEN: ${{ secrets.PRO_TOKEN }} | |
run: | | |
set -ex | |
detach() { | |
sudo pro detach --assume-yes || true | |
sudo rm -f /etc/apt/auth.conf.d/90ubuntu-advantage | |
} | |
trap detach EXIT | |
# Attach pro token and enable services | |
sudo pro attach ${PRO_TOKEN} --no-auto-enable | |
# Cannot enable fips and fips-updates at the same time. | |
# Hack: enable fips, copy the credentials and then after enabling | |
# other services, add the credentials back. | |
sudo pro enable fips --assume-yes | |
sudo cp /etc/apt/auth.conf.d/90ubuntu-advantage /etc/apt/auth.conf.d/90ubuntu-advantage.fips-creds | |
# This will disable the fips service. | |
sudo pro enable fips-updates esm-apps esm-infra --assume-yes | |
# Add the fips credentials back. | |
sudo sh -c 'cat /etc/apt/auth.conf.d/90ubuntu-advantage.fips-creds >> /etc/apt/auth.conf.d/90ubuntu-advantage' | |
sudo rm /etc/apt/auth.conf.d/90ubuntu-advantage.fips-creds | |
# Make apt credentials accessible to USER. | |
sudo setfacl -m u:$USER:r /etc/apt/auth.conf.d/90ubuntu-advantage | |
# Run tests on Pro real archives. | |
go test ./internal/archive/ --real-pro-archive | |
spread-tests: | |
name: Spread tests | |
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/checkout@v3 | |
with: | |
repository: snapcore/spread | |
path: _spread | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: '>=1.17.0' | |
- name: Build and run spread | |
env: | |
PRO_TOKEN: ${{ secrets.PRO_TOKEN }} | |
run: | | |
(cd _spread/cmd/spread && go build) | |
_spread/cmd/spread/spread -v tests/pro-archives |