Skip to content

Commit

Permalink
Merge branch 'main' into replace-badly-named-9p-option
Browse files Browse the repository at this point in the history
  • Loading branch information
electrofelix committed Sep 28, 2022
2 parents 4a5e13a + 0af8931 commit ff02dd4
Show file tree
Hide file tree
Showing 19 changed files with 292 additions and 123 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/docker-image.yml
Expand Up @@ -9,6 +9,18 @@ on:
pull_request:

jobs:
build-image-with-buildah:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: Build with buildah
run: buildah bud .

build-docker-image:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -54,12 +66,12 @@ jobs:
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2
with:
driver-opts: image=moby/buildkit:master
-
name: Cache Docker layers
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
Expand All @@ -80,7 +92,7 @@ jobs:
-
name: Build and push main image
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
Expand All @@ -101,7 +113,7 @@ jobs:
-
name: Build and push slim image
id: docker_build_slim
uses: docker/build-push-action@v2
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-tests.yml
Expand Up @@ -22,7 +22,7 @@ jobs:
libvirt-dev \
libz-dev \
;
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand Down Expand Up @@ -86,13 +86,13 @@ jobs:
# add user to group
sudo usermod -a -G libvirt $USER
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-${{ env.VAGRANT_VERSION }}
Expand Down
55 changes: 42 additions & 13 deletions .github/workflows/release.yml
Expand Up @@ -2,13 +2,17 @@ name: release

on:
push:
branches:
- '**'
tags:
- '*.*.*'

jobs:
release:
name: Create Release
release-notes:
name: Generate Release Notes
runs-on: ubuntu-latest
outputs:
release_branch: ${{ steps.prep.outputs.release_branch }}
steps:
-
name: Checkout code
Expand All @@ -17,13 +21,13 @@ jobs:
fetch-depth: 0
-
name: Determine remote default branch
uses: actions/github-script@v3.0.0
uses: actions/github-script@v6.2.0
id: remote_default_branch
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
repo = await github.repos.get({
repo = await github.rest.repos.get({
owner: context.repo.owner,
repo: context.repo.repo,
})
Expand All @@ -34,16 +38,24 @@ jobs:
run: |
set -eu -o pipefail
# exclude unreleased in case re-running workflow
echo "unreleased=false" >> .github_changelog_generator
echo "max-issues=200" >> .github_changelog_generator
# in case we've tagged subsequently ensure consistent run
NEXT_TAG_SHA1="$(git rev-list --tags --skip=0 --no-walk | grep -B 1 ${{ github.sha }} || true)"
if [[ "${NEXT_TAG_SHA1:-}" != "${{ github.sha }}" ]]
# cache requests to reduce load on API
echo "cache-file=.github_changelog_generator_cache" >> .github_changelog_generator
# only apply this section if triggered by a tag event
if [[ ${GITHUB_REF} == refs/tags/* ]]
then
NEXT_TAG=$(git describe --tags --abbrev=0 ${NEXT_TAG_SHA1})
echo "due-tag=${NEXT_TAG}" >> .github_changelog_generator
# exclude unreleased in case re-running workflow
echo "unreleased=false" >> .github_changelog_generator
# in case we've tagged subsequently ensure consistent run
NEXT_TAG_SHA1="$(git rev-list --tags --skip=0 --no-walk | grep -B 1 ${{ github.sha }} || true)"
if [[ "${NEXT_TAG_SHA1:-}" != "${{ github.sha }}" ]]
then
NEXT_TAG=$(git describe --tags --abbrev=0 ${NEXT_TAG_SHA1})
echo "due-tag=${NEXT_TAG}" >> .github_changelog_generator
fi
fi
# limit list to next tag if any
LAST_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || true)
Expand All @@ -67,17 +79,34 @@ jobs:
-
name: Cache Github API requests
id: cache-changelog-api-requests
uses: actions/cache@v2
uses: actions/cache@v3
with:
key: github-changelog-cache
path: .github_changelog_generator_cache
-
name: Changelog Generation
uses: CharMixer/auto-changelog-action@v1.4
with:
release_branch: ${{ steps.prep.outputs.release_branch }}
token: ${{ secrets.GITHUB_TOKEN }}
since_tag: ${{ steps.prep.outputs.previous_version }}
output: release_notes.md
-
uses: actions/upload-artifact@v2
with:
name: release-notes
path: release_notes.md

publish-release:
name: Create Release
needs: release-notes
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
-
uses: actions/download-artifact@v2
with:
name: release-notes
-
name: Create Release
id: create_release
Expand All @@ -86,6 +115,6 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
commitish: ${{ steps.prep.outputs.release_branch }}
commitish: ${{ needs.release-notes.outputs.release_branch }}
release_name: Release ${{ github.ref }}
body_path: release_notes.md
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Expand Up @@ -73,7 +73,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install libvirt-dev
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
Expand Down
31 changes: 14 additions & 17 deletions Dockerfile
@@ -1,4 +1,4 @@
# syntax = docker/dockerfile:1.3-labs
# syntax = docker/dockerfile:1.0-experimental
ARG VAGRANT_VERSION=2.3.0


Expand Down Expand Up @@ -38,8 +38,7 @@ FROM base as build
# allow caching of packages for build
RUN rm -f /etc/apt/apt.conf.d/docker-clean; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN sed -i '/deb-src/s/^# //' /etc/apt/sources.list
RUN --mount=id=apt-cache-v1,type=cache,target=/var/cache/apt --mount=id=apt-lib-v1,type=cache,target=/var/lib/apt \
apt update \
RUN apt update \
&& apt build-dep -y \
vagrant \
ruby-libvirt \
Expand All @@ -61,20 +60,18 @@ RUN find /opt/vagrant/embedded/ -type f | grep -v /opt/vagrant/embedded/plugins.

RUN /opt/vagrant/embedded/bin/gem install --install-dir /opt/vagrant/embedded/gems/${VAGRANT_VERSION} ./pkg/vagrant-libvirt*.gem

RUN cat <<EOF > /opt/vagrant/embedded/plugins.json
{
"version": "1",
"installed": {
"vagrant-libvirt": {
"ruby_version":"$(/opt/vagrant/embedded/bin/ruby -e 'puts RUBY_VERSION')",
"vagrant_version":"${VAGRANT_VERSION}",
"gem_version":"",
"require":"",
"sources":[]
}
}
}
EOF
RUN echo -n '{\n\
"version": "1",\n\
"installed": {\n\
"vagrant-libvirt": {\n\
"ruby_version": "'$(/opt/vagrant/embedded/bin/ruby -e 'puts "#{RUBY_VERSION}"')'",\n\
"vagrant_version": "'${VAGRANT_VERSION}'",\n\
"gem_version":"",\n\
"require":"",\n\
"sources":[]\n\
}\n\
}\n\
}' > /opt/vagrant/embedded/plugins.json

FROM build as pruned

Expand Down
6 changes: 6 additions & 0 deletions Gemfile
Expand Up @@ -45,3 +45,9 @@ end
group :plugins do
gemspec
end

group :test do
gem "test-prof", require: false
gem "ruby-prof", ">= 0.17.0", require: false
gem 'stackprof', '>= 0.2.9', require: false
end
2 changes: 1 addition & 1 deletion docs/Gemfile.lock
Expand Up @@ -13,7 +13,7 @@ GEM
execjs
coffee-script-source (1.11.1)
colorator (1.1.0)
commonmarker (0.23.5)
commonmarker (0.23.6)
concurrent-ruby (1.1.10)
dnsruby (1.61.9)
simpleidn (~> 0.1)
Expand Down
2 changes: 1 addition & 1 deletion docs/_includes/upstream-vagrant-install.html
@@ -1,7 +1,7 @@
* Upstream Vagrant Install<br />
Download and execute the vagrant-libvirt-qa install script (installs latest vagrant by default):
```shell
curl -O https://github.com/vagrant-libvirt/vagrant-libvirt-qa/blob/main/scripts/install.bash
curl -O https://raw.githubusercontent.com/vagrant-libvirt/vagrant-libvirt-qa/main/scripts/install.bash
chmod a+x ./install.bash
./install.bash
```
Expand Down
13 changes: 12 additions & 1 deletion lib/vagrant-libvirt/action/start_domain.rb
Expand Up @@ -429,9 +429,20 @@ def call(env)
raise Errors::UpdateServerError, error_message: e.message
end

# this normalises the attribute order to be the same as what was sent in the above
# request to update the domain XML. Without this, if the XML documents are not
# equivalent, many more differences will be reported than there actually are.
applied_xml = String.new
REXML::Document.new(libvirt_domain.xml_desc(1)).write(applied_xml)

# need to check whether the updated XML contains all the changes requested
proposed = VagrantPlugins::ProviderLibvirt::Util::Xml.new(new_xml)
applied = VagrantPlugins::ProviderLibvirt::Util::Xml.new(libvirt_domain.xml_desc(1))
applied = VagrantPlugins::ProviderLibvirt::Util::Xml.new(applied_xml)

# perform some sorting to allow comparison otherwise order of devices differing
# even if they are equivalent will be reported as being different.
proposed.xml['devices'][0].each { |_, v| next unless v.is_a?(Array); v.sort_by! { |e| [e['type'], e['index']]} }
applied.xml['devices'][0].each { |_, v| next unless v.is_a?(Array); v.sort_by! { |e| [e['type'], e['index']]} }

if proposed != applied
require 'diffy'
Expand Down
4 changes: 2 additions & 2 deletions lib/vagrant-libvirt/action/wait_till_up.rb
Expand Up @@ -23,7 +23,7 @@ def call(env)
env[:metrics] ||= {}

driver = env[:machine].provider.driver
domain = driver.get_domain(env[:machine])
domain = driver.get_domain

if domain.nil?
raise Errors::NoDomainError,
Expand All @@ -42,7 +42,7 @@ def call(env)
return if env[:interrupted]

# Wait for domain to obtain an ip address
env[:ip_address] = driver.get_domain_ipaddress(env[:machine], domain)
env[:ip_address] = driver.get_ipaddress(domain)
end
end
@logger.info("Got IP address #{env[:ip_address]}")
Expand Down

0 comments on commit ff02dd4

Please sign in to comment.