Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(tidy): Remove more cane references & update bats-core #33

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require:
- chefstyle

AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 3.1
Include:
- "**/*.rb"
Exclude:
Expand Down
5 changes: 5 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
extends: default

ignore:
- vendor
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ gemspec

group :guard do
gem "guard-cucumber"
gem "guard-cane"
gem "guard-rubocop"
end

Expand Down
12 changes: 3 additions & 9 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# -*- encoding: utf-8 -*-
ignore %r{^\.gem/}

def rubocop_opts
{ :all_on_start => false, :keep_failed => false, :cli => "-r finstyle -D" }
{ all_on_start: false, keep_failed: false, cli: "-r finstyle -D" }
end

group :red_green_refactor, :halt_on_fail => true do
group :red_green_refactor, halt_on_fail: true do
guard :cucumber do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { "features" }
Expand All @@ -15,12 +14,7 @@ group :red_green_refactor, :halt_on_fail => true do
end

guard :rubocop, rubocop_opts do
watch(%r{.+\.rb$})
watch(/.+\.rb$/)
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
end

guard :cane do
watch(%r{.*\.rb})
watch(".cane")
end
end
49 changes: 22 additions & 27 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
require "bundler/gem_tasks"
require "open-uri"

namespace :bats do
version = ENV.fetch("BATS_VERSION", "v0.4.0")
url = "https://github.com/sstephenson/bats/archive/#{version}.tar.gz"
tarball = "tmp/bats-#{version}.tar.gz"
vendor = "vendor/bats"

desc "Vendors bats #{version} source code into gem codebase"
task vendor: "#{vendor}/VERSION.txt"

directory File.dirname(tarball)
directory vendor

file tarball => File.dirname(tarball) do |t|
src = open(url).binmode
dst = open(t.name, "wb")
IO.copy_stream(src, dst)
ensure
src.close
dst.close
end

file "#{vendor}/VERSION.txt" => [vendor, tarball] do |t|
abs_tarball = File.expand_path(tarball)
Dir.chdir(vendor) { sh "tar xzf #{abs_tarball} --strip-components=1" }
rm_rf "#{vendor}/test"
IO.write(t.name, url + "\n")
desc "Vendor bats into gem codebase"
task :vendor do
version = ENV.fetch("BATS_VERSION", "v1.10.0")
url = "https://github.com/bats-core/bats-core/archive/refs/tags/#{version}.tar.gz"
tarball = "tmp/bats-#{version}.tar.gz"
vendor = "vendor/bats"

desc "Vendors bats #{version} source code into gem codebase"
task vendor: "#{vendor}/VERSION.txt"

directory File.dirname(tarball)
directory vendor

sh "curl -s -L #{url} -o #{tarball}"

file "#{vendor}/VERSION.txt" => [vendor, tarball] do |t|
abs_tarball = File.expand_path(tarball)
Dir.chdir(vendor) { sh "tar xzf #{abs_tarball} --strip-components=1" }
rm_rf "#{vendor}/test"
IO.write(t.name, url + "\n")
end
end

desc "Clean up a vendored bats in preparation for a new vendored version"
Expand All @@ -51,4 +46,4 @@ task :stats do
sh "countloc -r features"
end

task default: %i{test quality}
task default: %i{test}
17 changes: 17 additions & 0 deletions vendor/bats/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG bashver=latest

FROM bash:${bashver}

# Install parallel and accept the citation notice (we aren't using this in a
# context where it make sense to cite GNU Parallel).
RUN echo "@edgecomm http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
apk update && \
apk add --no-cache parallel ncurses shellcheck@edgecomm && \
mkdir -p ~/.parallel && touch ~/.parallel/will-cite && \
curl -sSfL https://github.com/shenwei356/rush/releases/download/v0.5.0/rush_linux_amd64.tar.gz | tar xzf - -C /usr/local/bin && \
chmod +x /usr/local/bin/rush

RUN ln -s /opt/bats/bin/bats /usr/sbin/bats
COPY . /opt/bats/

ENTRYPOINT ["bash", "/usr/sbin/bats"]
5 changes: 5 additions & 0 deletions vendor/bats/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Bats core development environment",
"dockerFile": "Dockerfile",
"build": {"args": {"bashver": "4.3"}}
}
35 changes: 35 additions & 0 deletions vendor/bats/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
root = true

[*]
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

# The JSON files contain newlines inconsistently
[*.json]
indent_size = 2
insert_final_newline = ignore

# YAML
[*.{yml,yaml}]
indent_style = space
indent_size = 2

# Makefiles always use tabs for recipe indentation
[{Makefile,*.mak}]
indent_style = tab

# Markdown
[*.{md,rmd,mkd,mkdn,mdwn,mdown,markdown,litcoffee}]
max_line_length = 80
# tabs behave as if they were replaced by spaces with a tab stop of 4 characters
tab_width = 4
# trailing spaces indicates word wrap
trim_trailing_spaces = false
trim_trailing_whitespace = false

[test/fixtures/bats/*_no_shellcheck.bats]
ignore = true
30 changes: 30 additions & 0 deletions vendor/bats/.github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'Priority: NeedsTriage, Type: Bug'
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Create example `file.bats` with following contents
2. run `bats --foo file.bats`
3. ...

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment (please complete the following information):**
- Bats version [e.g. 1.4.0 or commit hash if applicable]
- operating system (including version): [e.g. Linux (please name your distribution!), FreeBSD, MacOS]
- `bash --version`: [e.g. 5.1]
- Install method: [e.g. git submodule, distribution package manager, npm, homebrew, ...]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions vendor/bats/.github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: 'Priority: NeedsTriage, Type: Enhancement'
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context about the feature request here.
10 changes: 10 additions & 0 deletions vendor/bats/.github/workflows/check_pr_label.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/bash

get_pr_json() {
curl -s -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/bats-core/bats-core/pulls/$1"
}

PR_NUMBER="$1"
LABEL="$2"

get_pr_json "$PR_NUMBER" | jq .labels[].name | grep "$LABEL"
30 changes: 30 additions & 0 deletions vendor/bats/.github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release

on:
release: { types: [published] }
workflow_dispatch:

jobs:
npmjs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
registry-url: "https://registry.npmjs.org"
- run: npm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

github-npm:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
registry-url: "https://npm.pkg.github.com"
- name: scope package name as required by GitHub Packages
run: npm init -y --scope ${{ github.repository_owner }}
- run: npm publish --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions vendor/bats/.github/workflows/release_dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Release to docker hub

on:
release: { types: [published] }
workflow_dispatch:
inputs:
version:
description: 'Version to simulate for deploy'
required: true

jobs:
dockerhub:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- id: version
run: |
EXPECTED_VERSION=${{ github.event.inputs.version }}
TAG_VERSION=${GITHUB_REF#refs/tags/v} # refs/tags/v1.2.3 -> 1.2.3
echo ::set-output name=version::${EXPECTED_VERSION:-$TAG_VERSION}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1


- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log in to the GitHub Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
tags: ${{ secrets.DOCKER_USERNAME }}/bats:${{ steps.version.outputs.version }},${{ secrets.DOCKER_USERNAME }}/bats:latest
push: true

- uses: docker/build-push-action@v2
with:
platforms: linux/amd64,linux/arm64,linux/ppc64le,linux/s390x,linux/386,linux/arm/v7,linux/arm/v6
tags: ${{ secrets.DOCKER_USERNAME }}/bats:${{ steps.version.outputs.version }}-no-faccessat2,${{ secrets.DOCKER_USERNAME }}/bats:latest-no-faccessat2
push: true
build-args: bashver=5.1.4
72 changes: 72 additions & 0 deletions vendor/bats/.github/workflows/scorecard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This workflow uses actions that are not certified by GitHub. They are provided
# by a third-party and are governed by separate terms of service, privacy
# policy, and support documentation.

name: Scorecard supply-chain security
on:
# For Branch-Protection check. Only the default branch is supported. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
branch_protection_rule:
# To guarantee Maintained check is occasionally updated. See
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
schedule:
- cron: '44 10 * * 6'
push:
branches: [ "master" ]

# Declare default permissions as read only.
permissions: read-all

jobs:
analysis:
name: Scorecard analysis
runs-on: ubuntu-latest
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
# Needed to publish results and get a badge (see publish_results below).
id-token: write
# Uncomment the permissions below if installing in a private repository.
# contents: read
# actions: read

steps:
- name: "Checkout code"
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
with:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
with:
results_file: results.sarif
results_format: sarif
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
# - you want to enable the Branch-Protection check on a *public* repository, or
# - you are installing Scorecard on a *private* repository
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
# repo_token: ${{ secrets.SCORECARD_TOKEN }}

# Public repositories:
# - Publish results to OpenSSF REST API for easy access by consumers
# - Allows the repository to include the Scorecard badge.
# - See https://github.com/ossf/scorecard-action#publishing-results.
# For private repositories:
# - `publish_results` will always be set to `false`, regardless
# of the value entered here.
publish_results: true

# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
# format to the repository Actions tab.
- name: "Upload artifact"
uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
with:
name: SARIF file
path: results.sarif
retention-days: 5

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
with:
sarif_file: results.sarif
1 change: 1 addition & 0 deletions vendor/bats/.github/workflows/set_nounset.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set -u
Loading
Loading