diff --git a/.github/actions/install_packer/action.yml b/.github/actions/install_packer/action.yml index b7b1495..e79c317 100644 --- a/.github/actions/install_packer/action.yml +++ b/.github/actions/install_packer/action.yml @@ -16,6 +16,4 @@ runs: # Install packer.io curl -O https://releases.hashicorp.com/packer/${{ inputs.version }}/packer_${{ inputs.version }}_linux_amd64.zip unzip packer_${{ inputs.version }}_linux_amd64.zip - mkdir -p ~/bin/ chmod +x packer - mv packer ~/bin/packerio diff --git a/.github/actions/setup/action.yaml b/.github/actions/setup/action.yaml new file mode 100644 index 0000000..849cd19 --- /dev/null +++ b/.github/actions/setup/action.yaml @@ -0,0 +1,37 @@ +name: Setup environment +description: Sets up some basic components of the environment +inputs: + ansible: + description: Install Ansible as well + required: false + default: false +runs: + using: composite + steps: + - name: Checkout project + uses: actions/checkout@v3 + with: + submodules: recursive + - name: Install Python 3 + uses: actions/setup-python@v3 + with: + python-version: "3" + - name: Setup pip cache + uses: actions/cache@v3 + with: + path: ~/.cache/pip + key: python-pip + - name: Install Pip and tox + shell: bash + run: | + set -exo pipefail + python3 -m pip install -U pip + pip install -U wheel + pip install -U tox + - name: Install Ansible + if: inputs.ansible + shell: bash + run: | + set -exo pipefail + pip install -U ansible + ansible-galaxy collection install -r ansible/requirements.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7ba31b..5a160e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,35 +27,14 @@ jobs: fail-fast: false matrix: distro: ${{ fromJson( needs.collect.outputs.distros ) }} - packer_version: - - "1.8.0" needs_timeout: - distros/ubuntu-20.04-x86_64.pkrvars.hcl steps: - - uses: actions/checkout@v3 + - uses: ./.github/actions/setup with: - submodules: 'recursive' + ansible: true + - uses: ./.github/actions/install_packer - uses: greg-hellings/make-space@main - - uses: actions/setup-python@v3 - with: - python-version: "3" - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: python-pip - - name: install dependencies - shell: bash - run: | - set -e - sudo apt-get update - sudo apt-get install -y unzip cloud-utils qemu-system-{x86,ppc} - python3 -m pip install -U wheel - python3 -m pip install -U ansible - # Install packer.io - curl -O https://releases.hashicorp.com/packer/${{ matrix.packer_version }}/packer_${{ matrix.packer_version }}_linux_amd64.zip - unzip packer_${{ matrix.packer_version }}_linux_amd64.zip - mv packer packerio - chmod +x packerio - name: modify build timeouts, if necessary if: contains(matrix.needs_timeout, matrix.distro) shell: bash @@ -64,6 +43,8 @@ jobs: shell: bash run: | set -e + # Add a retry in case something bogus like a network failure happens + ./packerio build -var-file=${{ matrix.distro }} -var "qemu_accelerator=tcg" -except=upload sources || \ ./packerio build -var-file=${{ matrix.distro }} -var "qemu_accelerator=tcg" -except=upload sources env: VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fc8591b..f767c4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,17 +18,13 @@ jobs: name: Validate Packer templates are reasonable runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - submodules: true - - name: Install packer - uses: ./.github/actions/install_packer/ + - uses: ./.github/actions/setup + - uses: ./.github/actions/install_packer - name: Run syntax check run: | set -exo pipefail for vars in distros/*; do - ~/bin/packerio validate -except=upload -var-file=${vars} sources/ + packer validate -except=upload -var-file=${vars} sources/ done collect: @@ -37,19 +33,7 @@ jobs: outputs: all: ${{ steps.zipped.outputs.scenarios }} steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Set up Python - uses: actions/setup-python@v2 - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: python-pip - - name: Install dependencies - run: | - set -ex - python -m pip install --upgrade tox + - uses: ./.github/actions/setup - name: Collect dependencies id: collection uses: greg-hellings/tox-list@v1 @@ -74,20 +58,9 @@ jobs: name: Lint Ansible code runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: ./.github/actions/setup with: - submodules: true - - name: Install Python - uses: actions/setup-python@v2 - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: python-pip - - name: Install dependencies - run: |- - set -ex - python -m pip install --upgrade tox ansible - ansible-galaxy collection install -r ansible/requirements.yml + ansible: true - name: Run lint run: tox -e lint_all @@ -101,16 +74,6 @@ jobs: matrix: scenarios: "${{ fromJson(needs.collect.outputs.all) }}" steps: - - uses: actions/checkout@v3 - with: - submodules: true - - name: Install Python - uses: actions/setup-python@v2 - - uses: actions/cache@v3 - with: - path: ~/.cache/pip - key: python-pip - - name: Install dependencies - run: python -m pip install --upgrade tox + - uses: ./.github/actions/setup - name: Run scenario run: tox -e "${{ matrix.scenarios.scenario }}"