diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index cbec182..4a83cf9 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: @@ -14,28 +7,13 @@ on: branches: [ master ] jobs: - test-linux: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - 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 - - name: Run tests - run: bundle exec rspec - - test-mac: - runs-on: macos-14 + tests: + 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/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/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/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 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/cli_spec.rb b/spec/battlestation/cli_spec.rb new file mode 100644 index 0000000..f5ac61f --- /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)) + + allow(Output).to receive(:put_success) + allow(Output).to receive(:put_info) + + subject.run + 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