From 5ab300e24ab37be04b098149134b06e2d1bd9508 Mon Sep 17 00:00:00 2001 From: Michael Bachand Date: Sat, 11 Oct 2025 16:58:17 -0700 Subject: [PATCH 1/7] modernize CI and remove unused in-progress symlinks code --- .github/workflows/ruby.yml | 25 +++++----------- bin/sync_symlinks | 48 ------------------------------ config/symlinks.yaml | 16 ---------- lib/battlestation.rb | 1 - lib/battlestation/symlink.rb | 17 ----------- spec/battlestation/symlink_spec.rb | 16 ---------- 6 files changed, 7 insertions(+), 116 deletions(-) delete mode 100755 bin/sync_symlinks delete mode 100644 config/symlinks.yaml delete mode 100644 lib/battlestation/symlink.rb delete mode 100644 spec/battlestation/symlink_spec.rb diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index cbec182..23ddfbc 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -1,10 +1,3 @@ -# 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. -# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake -# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby - name: Ruby on: @@ -17,25 +10,21 @@ jobs: test-linux: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v5 - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # (see https://github.com/ruby/setup-ruby#versioning): uses: ruby/setup-ruby@v1 - - name: Install dependencies - run: bundle install + with: + bundler-cache: true - name: Run tests run: bundle exec rspec test-mac: - runs-on: macos-14 + runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # (see https://github.com/ruby/setup-ruby#versioning): uses: ruby/setup-ruby@v1 - - name: Install dependencies - run: bundle install + with: + bundler-cache: true - name: Run tests run: bundle exec rspec diff --git a/bin/sync_symlinks b/bin/sync_symlinks deleted file mode 100755 index 42b41fc..0000000 --- a/bin/sync_symlinks +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env ruby - -# TODO: This is a WIP that will replace `create_link()` in setup.sh - -require 'optparse' -require 'yaml' -require 'pathname' - -require_relative '../lib/output' - -optparse = OptionParser.new do |opts| - opts.banner = "Usage: #{File.basename(__FILE__)} yaml_path" - - opts.on( '-h', '--help', 'Display usage' ) do - Output.put_info(opts) - exit 1 - end -end - -optparse.parse! - -unless ARGV.count == 1 - Output.put_error('Specify a single file.') - exit 1 -end - -yaml_path = ARGV[0] - -unless File.exists? yaml_path - Output.put_error("#{yaml_path} does not exist.") - exit 1 -end - -yaml = YAML.load_file(yaml_path) - -unless yaml.is_a? Array - Output.put_error("File must be a YAML array.") - exit 1 -end - -Symlink = Struct.new(:target_path, :source_path) -symlinks = yaml.map do |element| - target_path = element['target_path'] - source_path = element['source_path'] - Symlink.new(target_path, source_path) -end - -puts symlinks.inspect diff --git a/config/symlinks.yaml b/config/symlinks.yaml deleted file mode 100644 index f5228e8..0000000 --- a/config/symlinks.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# Symbolic links to create. -# Relatives target paths are relative to $HOME. Relative source paths are relative to the root of -# this repo. Absolute paths are not modified. ---- -- target_path: .gitconfig - source_path: dotfiles/gitconfig - -- target_path: .npmrc - source_path: dotfiles/npmrc - -- target_path: Library/Application Support/Code/User/settings.json - source_path: vscode_settings.json - - -- target_path: /usr/local/bin/git-cleanup - source_path: git-cleanup diff --git a/lib/battlestation.rb b/lib/battlestation.rb index 084501a..02bdce6 100644 --- a/lib/battlestation.rb +++ b/lib/battlestation.rb @@ -1,2 +1 @@ require_relative 'battlestation/cli.rb' -require_relative 'battlestation/symlink.rb' diff --git a/lib/battlestation/symlink.rb b/lib/battlestation/symlink.rb deleted file mode 100644 index 774ea63..0000000 --- a/lib/battlestation/symlink.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module Battlestation - - # A value type representing a symbolic link. - class Symlink - - def initialize(source_file, link_pathname) - @source_file = source_file - @link_pathname = link_pathname - end - - def exists? - raise NotImplementedError, "todo..." - end - end -end diff --git a/spec/battlestation/symlink_spec.rb b/spec/battlestation/symlink_spec.rb deleted file mode 100644 index 82e1482..0000000 --- a/spec/battlestation/symlink_spec.rb +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -require 'battlestation' - -RSpec.describe Battlestation::Symlink do - - describe '#exists?', :isolated_directory do - before do - # create files - end - - it 'blah' do - expect(true).to be_truthy - end - end -end From e15287e3f9871013b10637450037485cf8002e0f Mon Sep 17 00:00:00 2001 From: Michael Bachand Date: Sat, 11 Oct 2025 17:09:28 -0700 Subject: [PATCH 2/7] add test --- spec/battlestation/cli_spec.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec/battlestation/cli_spec.rb diff --git a/spec/battlestation/cli_spec.rb b/spec/battlestation/cli_spec.rb new file mode 100644 index 0000000..d6e573c --- /dev/null +++ b/spec/battlestation/cli_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' +require_relative '../../lib/battlestation/cli' + +describe Battlestation::CLI do + + describe '#run' do + it 'runs each setup step and returns shell exit status' do + expect(subject).to receive(:install_terminal_theme).with(kind_of(Pathname)) + expect(subject).to receive(:configure_xcode) + expect(subject).to receive(:run_legacy_setup_script).with(kind_of(Pathname)) + expect(subject).to receive(:install_python) + expect(subject).to receive(:install_aws_cli) + expect(subject).to receive(:update_homebrew) + expect(subject).to receive(:install_packages) + expect(subject).to receive(:configure_fzf) + expect(subject).to receive(:install_ruby).with('2.7.6') + expect(subject).to receive(:set_ruby_version).with('2.7.6') + expect(subject).to receive(:install_gems).with(kind_of(Pathname)) { system('true') } + + allow(Output).to receive(:put_success) + allow(Output).to receive(:put_info) + + expect(subject.run).to eq(0) + end + end +end From d6c8a379705f7308f4d21ff526d28fbe1f3b2d85 Mon Sep 17 00:00:00 2001 From: Michael Bachand Date: Sat, 11 Oct 2025 17:10:14 -0700 Subject: [PATCH 3/7] tweaks --- .github/workflows/ruby.yml | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 23ddfbc..4a83cf9 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -7,18 +7,7 @@ on: branches: [ master ] jobs: - test-linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - name: Run tests - run: bundle exec rspec - - test-mac: + tests: runs-on: macos-latest steps: - uses: actions/checkout@v5 From 022544be7f224846c3f39968f4179a2ceeba8e48 Mon Sep 17 00:00:00 2001 From: Michael Bachand Date: Sat, 11 Oct 2025 17:12:22 -0700 Subject: [PATCH 4/7] tweak --- spec/battlestation/cli_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/battlestation/cli_spec.rb b/spec/battlestation/cli_spec.rb index d6e573c..c319d3e 100644 --- a/spec/battlestation/cli_spec.rb +++ b/spec/battlestation/cli_spec.rb @@ -15,7 +15,7 @@ expect(subject).to receive(:configure_fzf) expect(subject).to receive(:install_ruby).with('2.7.6') expect(subject).to receive(:set_ruby_version).with('2.7.6') - expect(subject).to receive(:install_gems).with(kind_of(Pathname)) { system('true') } + expect(subject).to receive(:install_gems).with(kind_of(Pathname)) allow(Output).to receive(:put_success) allow(Output).to receive(:put_info) From 5bdbacc6645784ed39ea5c2fe23db46fd7629f21 Mon Sep 17 00:00:00 2001 From: Michael Bachand Date: Sat, 11 Oct 2025 17:22:08 -0700 Subject: [PATCH 5/7] remove exit status --- bin/battlestation | 4 +--- lib/battlestation/cli.rb | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/bin/battlestation b/bin/battlestation index 8d6527a..c51425f 100755 --- a/bin/battlestation +++ b/bin/battlestation @@ -6,6 +6,4 @@ $LOAD_PATH.unshift("#{__dir__}/../lib") require 'battlestation' cli = Battlestation::CLI.new -result = cli.run - -exit result +cli.run diff --git a/lib/battlestation/cli.rb b/lib/battlestation/cli.rb index 1bcabc8..6a0228e 100644 --- a/lib/battlestation/cli.rb +++ b/lib/battlestation/cli.rb @@ -15,7 +15,6 @@ class CLI # inspect the target files. # # @param args [Array] command line arguments - # @return [Integer] UNIX exit code def run(args = ARGV) current_dirname = Pathname.new(__FILE__).dirname @@ -46,8 +45,6 @@ def run(args = ARGV) Output.put_success("Setup completed.") Output.put_info("Please close and reopen your shell.") - - return $?.exitstatus end private From 9d7abe5b7131f45424efd491d588e07cae58b7ac Mon Sep 17 00:00:00 2001 From: Michael Bachand Date: Sat, 11 Oct 2025 17:24:43 -0700 Subject: [PATCH 6/7] fix tests --- spec/battlestation/cli_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/battlestation/cli_spec.rb b/spec/battlestation/cli_spec.rb index c319d3e..4364988 100644 --- a/spec/battlestation/cli_spec.rb +++ b/spec/battlestation/cli_spec.rb @@ -19,8 +19,6 @@ allow(Output).to receive(:put_success) allow(Output).to receive(:put_info) - - expect(subject.run).to eq(0) end end end From e64776f74e1cc94e1998fa4a1afbf2dfcf3362c8 Mon Sep 17 00:00:00 2001 From: Michael Bachand Date: Sat, 11 Oct 2025 17:26:27 -0700 Subject: [PATCH 7/7] oops --- spec/battlestation/cli_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/battlestation/cli_spec.rb b/spec/battlestation/cli_spec.rb index 4364988..f5ac61f 100644 --- a/spec/battlestation/cli_spec.rb +++ b/spec/battlestation/cli_spec.rb @@ -19,6 +19,8 @@ allow(Output).to receive(:put_success) allow(Output).to receive(:put_info) + + subject.run end end end