diff --git a/.clang-tidy b/.clang-tidy index 20b4175..fd3f4ac 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -26,4 +26,4 @@ CheckOptions: - key: readability-identifier-naming.FunctionCase value: camelBack - key: readability-magic-numbers.IgnoredIntegerValues - value: {1, 2, 3, 4, 5, 6, 7, 8, 9} + value: 1;2;3;4;5;6;7;8;9; diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml new file mode 100644 index 0000000..d15d891 --- /dev/null +++ b/.github/workflows/pull.yml @@ -0,0 +1,22 @@ +name: Pull Actions + +on: [pull_request, pull_request_review, pull_request_review_comment] + +jobs: + danger: + name: Danger Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: '2.6' + - name: Setup environment + run: | + gem install bundler -v 2.1.4 + bundle install --jobs 4 --retry 3 + - name: Run Danger + run: | + export DANGER_GITHUB_API_TOKEN=${{ secrets.BOT_TOKEN }} + bundle exec danger --verbose diff --git a/.github/workflows/build.yml b/.github/workflows/push.yml similarity index 82% rename from .github/workflows/build.yml rename to .github/workflows/push.yml index bf41e13..3e37293 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/push.yml @@ -1,9 +1,10 @@ -name: Build & test CI +name: Push Actions on: [push] jobs: build: + name: CI Build strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] @@ -46,7 +47,9 @@ jobs: run: ninja -C build - name: Test run: ninja -C build test + minify: + name: File Minify runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -58,3 +61,17 @@ jobs: with: name: Minified artifacts path: artifacts + + semver: + name: Semantic Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Node.js + uses: actions/setup-node@v1 + with: + node-version: 12 + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx semantic-release diff --git a/.gitignore b/.gitignore index 3dfbf54..d8a3813 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ build/ cmake-*/ vgcore.* core.* +.vagrant/ +.bundle/ diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 7fba9e6..2205157 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -2,7 +2,7 @@ FROM gitpod/workspace-full:build-branch-master USER root -# Install packages +# Install system packages RUN apt-get update \ && apt-get install -yq --no-install-recommends \ python3=3.7.3-1 \ @@ -11,10 +11,40 @@ RUN apt-get update \ python3-wheel=0.32.3-2 \ valgrind=1:3.14.0-2ubuntu6 \ ccache=3.6-1 \ - && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* \ - && /usr/sbin/update-ccache-symlinks + && /usr/sbin/update-ccache-symlinks \ + && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* + +# Disable Vagrant stuff for now. When VM's are supported, this will be uncommented. +# # Install libvirt packages +# RUN apt-get update \ +# && apt-get install -yq --no-install-recommends \ +# ruby-libvirt=0.7.1-1 \ +# && apt-get install -yq --no-install-recommends \ +# qemu=1:3.1+dfsg-2ubuntu3.7 \ +# qemu-kvm=1:3.1+dfsg-2ubuntu3.7 \ +# qemu-utils=1:3.1+dfsg-2ubuntu3.7 \ +# libvirt-daemon-system=5.0.0-1ubuntu2.6 \ +# libvirt-clients=5.0.0-1ubuntu2.6 \ +# ebtables=2.0.10.4+snapshot20181205-1ubuntu1 \ +# dnsmasq-base=2.80-1ubuntu1 \ +# && apt-get install -yq --no-install-recommends \ +# libxslt1-dev=1.1.32-2ubuntu0.2 \ +# libxml2-dev=2.9.4+dfsg1-7ubuntu3 \ +# libvirt-dev=5.0.0-1ubuntu2.6 \ +# zlib1g-dev=1:1.2.11.dfsg-1ubuntu2 \ +# ruby-dev=1:2.5.1 \ +# && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* + +# # Download and install Vagrant +# RUN curl -O https://releases.hashicorp.com/vagrant/2.2.7/vagrant_2.2.7_x86_64.deb \ +# && apt install ./vagrant_2.2.7_x86_64.deb \ +# && usermod -a -G libvirt gitpod \ +# && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* USER gitpod -# Install pip packages -RUN python3 -m pip install pip==20.0.2 meson==0.53.0 gcovr==4.2 ninja==1.9.0.post1 +# Install packages +RUN python3 -m pip install pip==20.0.2 meson==0.53.0 gcovr==4.2 ninja==1.9.0.post1 \ + && brew install git-flow +# && bundle install +# && vagrant plugin install vagrant-libvirt diff --git a/.gitpod.yml b/.gitpod.yml index 79f065a..43c2799 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,6 +1,12 @@ +tasks: + - init: + bundle install --jobs 4 --retry 3 image: file: .gitpod.Dockerfile vscode: extensions: - asabil.meson@1.2.0:sYg01j3Mm+6RJtaIRwyR5A== - - ms-vscode.cpptools@0.26.3:Pq/tmf2WN3SanVzB4xZc1g== + - bbenoist.vagrant@0.5.0:e2ktoGsnar8weYYRNdvexg== +# - wingrunr21.vscode-ruby@0.26.0:VakXVw0C77hAQ3U3AZTn1Q== +# - rebornix.ruby@0.26.0:RN+gv0dPjYfMqlcEEralhg== + - Orta.vscode-danger@1.0.1:cGUzsroSPSoihE2Yps+qbA== diff --git a/.releaserc b/.releaserc new file mode 100644 index 0000000..17cb5e2 --- /dev/null +++ b/.releaserc @@ -0,0 +1,9 @@ +branches: + - master + - name: 'release?(/*)' + prerelease: true + +plugins: + - '@semantic-release/commit-analyzer' + - '@semantic-release/release-notes-generator' + - '@semantic-release/github' diff --git a/Dangerfile b/Dangerfile new file mode 100644 index 0000000..2caf912 --- /dev/null +++ b/Dangerfile @@ -0,0 +1,45 @@ +# Check if the Dangerfile was changed +has_dangerfile_changes = git.modified_files.include? "Dangerfile" +# Check if the Gemfile was changed +has_gemfile_changes = git.modified_files.include? "Gemfile" +# Check if the license file was changed +has_license_changes = git.modified_files.include? "UNLICENSE" +# Check if the header was changed +has_app_changes = git.modified_files.include? "assertions.h" +# Check if any of the tests were changed +has_test_changes = !git.modified_files.grep(/test/).empty? +# Check if the PR is trivial +declared_trivial = (github.pr_title + github.pr_body).include?("#trivial") || !has_app_changes + +# Allow Bitmodo members to bypass some checks +unless github.api.organization_member?('bitmodo', github.pr_author) + # Fail if the PR does not provide a description + failure "Please provide a summary in the Pull Request description" if github.pr_body.length < 5 + + # Fail if the license was modified by an external user + failure "The license has been modified" if has_license_changes + + # Warn if the Dangerfile was changed by an external contributor + warn "#{github.html_link("Dangerfile")} has been modified by external contributor" if has_dangerfile_changes + + # Warn if the Gemfile was changed by an external contributor + warn "#{github.html_link("Gemfile")} has been modified by external contributor" if has_gemfile_changes + + # Provide a thanks message if the user is external + message ":+1: Thank you for contributing!" +else + # Warn if the license has been modified + warn "The license has been modified" if has_license_changes + + # Provide a message if the user is internal + message ":ok_hand:" +end + +# Warn if the header has changed but the tests have not +warn "Tests have not been updated" if has_app_changes && !has_test_changes && !declared_trivial +# Create a warning if the PR is a work in progress +warn "PR is classed as Work in Progress" if github.pr_title.include? "[WIP]" +# Warn if the PR is not assigned to anyone +warn "This PR does not have any assignees yet." unless github.pr_json["assignee"] +# Warn if the PR is not mergeable +warn "This PR cannot be merged yet" unless github.pr_json["mergeable"] diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..9607a6c --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem 'danger', '6.3.0' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..60d0c24 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,59 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) + claide (1.0.3) + claide-plugins (0.9.2) + cork + nap + open4 (~> 1.3) + colored2 (3.1.2) + cork (0.3.0) + colored2 (~> 3.1) + danger (6.3.0) + claide (~> 1.0) + claide-plugins (>= 0.9.2) + colored2 (~> 3.1) + cork (~> 0.1) + faraday (~> 0.9) + faraday-http-cache (~> 2.0) + git (~> 1.6) + kramdown (~> 2.0) + kramdown-parser-gfm (~> 1.0) + no_proxy_fix + octokit (~> 4.7) + terminal-table (~> 1) + faraday (0.17.3) + multipart-post (>= 1.2, < 3) + faraday-http-cache (2.0.0) + faraday (~> 0.8) + git (1.6.0) + rchardet (~> 1.8) + kramdown (2.1.0) + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + multipart-post (2.1.1) + nap (1.1.0) + no_proxy_fix (0.1.2) + octokit (4.16.0) + faraday (>= 0.9) + sawyer (~> 0.8.0, >= 0.5.3) + open4 (1.3.4) + public_suffix (4.0.3) + rchardet (1.8.0) + sawyer (0.8.2) + addressable (>= 2.3.5) + faraday (> 0.8, < 2.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + unicode-display_width (1.6.1) + +PLATFORMS + ruby + +DEPENDENCIES + danger (= 6.3.0) + +BUNDLED WITH + 2.1.4 diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..1b2f034 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,24 @@ +Vagrant.configure("2") do |config| + # Use Ubuntu 19.04 as the default box + config.vm.box = "generic/ubuntu1904" + config.vm.box_version = "2.0.6" + + config.vm.provider :libvirt do |libvirt| + # Use QEMU session instead of system connection + libvirt.qemu_use_session = true + # URI of QEMU session connection, default is as below + libvirt.uri = 'qemu:///session' + # URI of QEMU system connection, use to obtain IP address for management, default is below + libvirt.system_uri = 'qemu:///system' + # Path to store Libvirt images for the virtual machine, default is as ~/.local/share/libvirt/images + libvirt.storage_pool_path = '/home/gitpod/.local/share/libvirt/images' + # Management network device, default is below + libvirt.management_network_device = 'virbr0' + end + + # Public network configuration using existing network device + # Note: Private networks do not work with QEMU session enabled as root access is required to create new network devices + config.vm.network :public_network, :dev => "virbr1", + :mode => "bridge", + :type => "bridge" +end diff --git a/assertions.h b/assertions.h index be39faa..8851ad6 100644 --- a/assertions.h +++ b/assertions.h @@ -9,8 +9,8 @@ * apart from variadic utility macros. */ -#ifndef _ASSERTIONS_H -#define _ASSERTIONS_H +#ifndef ASSERTIONS_H +#define ASSERTIONS_H #include #include