From 19d21fe36d6257dac59fcd2e5f6c2454a9e8a13a Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 10:32:52 -0600 Subject: [PATCH 1/9] coder 2.1.4 --- .github/workflows/test.yml | 41 ++++++++++++++++++++++++++++++++ Formula/coder.rb | 31 ++++++++++++++++++++++++ coder@1.rb => Formula/coder@1.rb | 0 3 files changed, 72 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 Formula/coder.rb rename coder@1.rb => Formula/coder@1.rb (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..249c70a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,41 @@ +name: test + +on: + push: + branches: ["main"] + pull_request: + branches: ["**"] + +jobs: + test: + strategy: + matrix: + os: [ubuntu-22.04, macos-13] + + runs-on: ${{ matrix.os }} + + steps: + - name: Set up Homebrew + id: set-up-homebrew + uses: Homebrew/actions/setup-homebrew@master + + - name: Cache Homebrew Bundler RubyGems + id: cache + uses: actions/cache@v3 + with: + path: ${{ steps.set-up-homebrew.outputs.gems-path }} + key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} + restore-keys: ${{ runner.os }}-rubygems- + + - name: Install Homebrew Bundler RubyGems + if: steps.cache.outputs.cache-hit != 'true' + run: brew install-bundler-gems + + - run: brew test-bot --only-cleanup-before + + - run: brew test-bot --only-setup + + - run: brew test-bot --only-tap-syntax + + - run: brew test-bot --only-formulae + if: github.event_name == 'pull_request' diff --git a/Formula/coder.rb b/Formula/coder.rb new file mode 100644 index 0000000..ec93658 --- /dev/null +++ b/Formula/coder.rb @@ -0,0 +1,31 @@ +class Coder < Formula + desc "Provisions remote development environments via Terraform" + homepage "https://github.com/coder/coder" + version "2.1.4" + + if OS.mac? + if Hardware::CPU.arm? + url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_darwin_arm64.zip" + sha256 "ac67c032e81fed7ef3b2e1fc5bfafb878e7551c081d0a136f5a88583c279c060" + else + url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_darwin_amd64.zip" + sha256 "693d6c450891627d879123ea9a08dc5917dafee7de6c639c5c9b496abe6f250b" + end + else + url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_linux_amd64.tar.gz" + sha256 "41666bbe3afacd153fbe6c1a2d908bb4fb7a88e821205cb7136a0bad2d1cd6dc" + end + + def install + bin.install "coder" + end + test do + version_output = shell_output("#{bin}/coder version") + assert_match version.to_s, version_output + refute_match "AGPL", version_output + assert_match "Full build", version_output + + assert_match "You are not logged in", shell_output("#{bin}/coder netcheck 2>&1", 1) + assert_match "postgres://", shell_output("#{bin}/coder server postgres-builtin-url") + end +end diff --git a/coder@1.rb b/Formula/coder@1.rb similarity index 100% rename from coder@1.rb rename to Formula/coder@1.rb From f3e9290230a677a37fc92747bbc7b8481b47c873 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 10:42:40 -0600 Subject: [PATCH 2/9] fix indentation --- .github/workflows/test.yml | 1 + Formula/coder.rb | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 249c70a..e8eb997 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,6 +9,7 @@ on: jobs: test: strategy: + fail-fast: false matrix: os: [ubuntu-22.04, macos-13] diff --git a/Formula/coder.rb b/Formula/coder.rb index ec93658..d6cc8eb 100644 --- a/Formula/coder.rb +++ b/Formula/coder.rb @@ -4,13 +4,13 @@ class Coder < Formula version "2.1.4" if OS.mac? - if Hardware::CPU.arm? - url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_darwin_arm64.zip" - sha256 "ac67c032e81fed7ef3b2e1fc5bfafb878e7551c081d0a136f5a88583c279c060" - else - url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_darwin_amd64.zip" - sha256 "693d6c450891627d879123ea9a08dc5917dafee7de6c639c5c9b496abe6f250b" - end + if Hardware::CPU.arm? + url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_darwin_arm64.zip" + sha256 "ac67c032e81fed7ef3b2e1fc5bfafb878e7551c081d0a136f5a88583c279c060" + else + url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_darwin_amd64.zip" + sha256 "693d6c450891627d879123ea9a08dc5917dafee7de6c639c5c9b496abe6f250b" + end else url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_linux_amd64.tar.gz" sha256 "41666bbe3afacd153fbe6c1a2d908bb4fb7a88e821205cb7136a0bad2d1cd6dc" From ccbae36210d6d7c91a08643a2be29cae01f595e3 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 10:58:39 -0600 Subject: [PATCH 3/9] use `version` --- .github/workflows/test.yaml | 32 -------------------------------- Formula/coder.rb | 7 ++++--- Formula/coder@1.rb | 11 +++++++++-- 3 files changed, 13 insertions(+), 37 deletions(-) delete mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml deleted file mode 100644 index 9bb02a2..0000000 --- a/.github/workflows/test.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: test -on: [push] - -jobs: - coder_cli: - strategy: - matrix: - os: [macos-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v1 - - run: | - if [[ "$(uname -s)" == "Linux" ]] - then - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - fi - - run: brew install --build-from-source ./coder-cli.rb - - run: coder --version - coder_cli_nightly: - strategy: - matrix: - os: [macos-latest, ubuntu-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v1 - - run: | - if [[ "$(uname -s)" == "Linux" ]] - then - echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - fi - - run: brew install --build-from-source ./coder-cli-nightly.rb - - run: coder --version diff --git a/Formula/coder.rb b/Formula/coder.rb index d6cc8eb..2121f9b 100644 --- a/Formula/coder.rb +++ b/Formula/coder.rb @@ -5,20 +5,21 @@ class Coder < Formula if OS.mac? if Hardware::CPU.arm? - url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_darwin_arm64.zip" + url "https://github.com/coder/coder/releases/download/v#{version}/coder_#{version}_darwin_arm64.zip" sha256 "ac67c032e81fed7ef3b2e1fc5bfafb878e7551c081d0a136f5a88583c279c060" else - url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_darwin_amd64.zip" + url "https://github.com/coder/coder/releases/download/v#{version}/coder_#{version}_darwin_amd64.zip" sha256 "693d6c450891627d879123ea9a08dc5917dafee7de6c639c5c9b496abe6f250b" end else - url "https://github.com/coder/coder/releases/download/v2.1.4/coder_2.1.4_linux_amd64.tar.gz" + url "https://github.com/coder/coder/releases/download/v#{version}/coder_#{version}_linux_amd64.tar.gz" sha256 "41666bbe3afacd153fbe6c1a2d908bb4fb7a88e821205cb7136a0bad2d1cd6dc" end def install bin.install "coder" end + test do version_output = shell_output("#{bin}/coder version") assert_match version.to_s, version_output diff --git a/Formula/coder@1.rb b/Formula/coder@1.rb index 99a30c1..e1033f9 100644 --- a/Formula/coder@1.rb +++ b/Formula/coder@1.rb @@ -4,16 +4,23 @@ class CoderAT1 < Formula version "1.44.0" if OS.mac? - url "https://github.com/coder/coder-v1-cli/releases/download/v1.44.0/coder-cli-darwin-amd64.zip" + url "https://github.com/coder/coder-v1-cli/releases/download/v#{version}/coder-cli-darwin-amd64.zip" sha256 "f3fe13cec4d0615a40134675279d4cd1a5a871356d90dedef020981622f1b693" # mac else - url "https://github.com/coder/coder-v1-cli/releases/download/v1.44.0/coder-cli-linux-amd64.tar.gz" + url "https://github.com/coder/coder-v1-cli/releases/download/v#{version}/coder-cli-linux-amd64.tar.gz" sha256 "642320e709a8585ae732e3b31d5945a09cd2a7d63121d7121c34ebc5740d3fc9" # linux end + keg_only :versioned_formula + + def version_suffix + version.major.to_s + end + def install bin.install "coder" end + test do system "#{bin}/coder", "--version" end From 41fa32af1fff8d846eef6b3498111bb7b74d1720 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 11:48:06 -0600 Subject: [PATCH 4/9] ah, gnu-sed --- Formula/coder@1.rb | 4 ++-- ci/{update.sh => update-v1.sh} | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) rename ci/{update.sh => update-v1.sh} (64%) diff --git a/Formula/coder@1.rb b/Formula/coder@1.rb index e1033f9..8738698 100644 --- a/Formula/coder@1.rb +++ b/Formula/coder@1.rb @@ -5,10 +5,10 @@ class CoderAT1 < Formula if OS.mac? url "https://github.com/coder/coder-v1-cli/releases/download/v#{version}/coder-cli-darwin-amd64.zip" - sha256 "f3fe13cec4d0615a40134675279d4cd1a5a871356d90dedef020981622f1b693" # mac + sha256 "f3fe13cec4d0615a40134675279d4cd1a5a871356d90dedef020981622f1b693" else url "https://github.com/coder/coder-v1-cli/releases/download/v#{version}/coder-cli-linux-amd64.tar.gz" - sha256 "642320e709a8585ae732e3b31d5945a09cd2a7d63121d7121c34ebc5740d3fc9" # linux + sha256 "642320e709a8585ae732e3b31d5945a09cd2a7d63121d7121c34ebc5740d3fc9" end keg_only :versioned_formula diff --git a/ci/update.sh b/ci/update-v1.sh similarity index 64% rename from ci/update.sh rename to ci/update-v1.sh index 5d86f35..34a5691 100755 --- a/ci/update.sh +++ b/ci/update-v1.sh @@ -12,17 +12,17 @@ darwin_sha="$(echo "$2" | tr "[:upper:]" "[:lower:]")" linux_sha="$(echo "$3" | tr "[:upper:]" "[:lower:]")" # Get the old version to use in our find/replace. -old_version="$(sed -n "s/.*version \"\(.*\)\".*/\1/p" "../coder@1.rb")" +old_version="$(sed -n "s/.*version \"\(.*\)\".*/\1/p" "../Formula/coder@1.rb")" if [[ "$old_version" == "" ]]; then echo "Could not determine the old version of the formula..." >&2 exit 1 fi # Replace version -sed -i '' "s/${old_version//./\.}/${version//./\.}/g" "../coder@1.rb" +sed -i "s/${old_version//./\.}/${version//./\.}/g" "../Formula/coder@1.rb" # Update macOS hash -sed -i '' "s/sha256 \"[a-f0-9]*\" # mac/sha256 \"$darwin_sha\" # mac/" "../coder@1.rb" +sed -zi "s/sha256 \"[a-f0-9]*\"/sha256 \"$darwin_sha\"/1" "../Formula/coder@1.rb" # Update Linux hash -sed -i '' "s/sha256 \"[a-f0-9]*\" # linux/sha256 \"$linux_sha\" # linux/" "../coder@1.rb" +sed -zi "s/sha256 \"[a-f0-9]*\"/sha256 \"$linux_sha\"/2" "../Formula/coder@1.rb" From f2ff8a47ba1f141a9054bc82a86cbbd4f1ea47f4 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 11:51:39 -0600 Subject: [PATCH 5/9] and nice script cleanup --- ci/update-v1.sh | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/ci/update-v1.sh b/ci/update-v1.sh index 34a5691..a48a608 100755 --- a/ci/update-v1.sh +++ b/ci/update-v1.sh @@ -11,15 +11,8 @@ version="$1" darwin_sha="$(echo "$2" | tr "[:upper:]" "[:lower:]")" linux_sha="$(echo "$3" | tr "[:upper:]" "[:lower:]")" -# Get the old version to use in our find/replace. -old_version="$(sed -n "s/.*version \"\(.*\)\".*/\1/p" "../Formula/coder@1.rb")" -if [[ "$old_version" == "" ]]; then - echo "Could not determine the old version of the formula..." >&2 - exit 1 -fi - # Replace version -sed -i "s/${old_version//./\.}/${version//./\.}/g" "../Formula/coder@1.rb" +sed -i "s/version \"[0-9.]*\"/version \"$version\"/g" "../Formula/coder@1.rb" # Update macOS hash sed -zi "s/sha256 \"[a-f0-9]*\"/sha256 \"$darwin_sha\"/1" "../Formula/coder@1.rb" From f10257d4c473f452a1cdecee38dd123cddf6f0a9 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 11:55:14 -0600 Subject: [PATCH 6/9] add v2 update script --- ci/update-v2.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 ci/update-v2.sh diff --git a/ci/update-v2.sh b/ci/update-v2.sh new file mode 100755 index 0000000..b44eaf2 --- /dev/null +++ b/ci/update-v2.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Updates both the coder-cli and coder-cli-nightly formulae to have the given +# values. +# ./update.sh "" "" "" "" + +set -euo pipefail +cd "$(dirname "$0")" + +version="$1" +darwin_arm_sha="$(echo "$2" | tr "[:upper:]" "[:lower:]")" +darwin_intel_sha="$(echo "$3" | tr "[:upper:]" "[:lower:]")" +linux_sha="$(echo "$4" | tr "[:upper:]" "[:lower:]")" + +# Replace version +sed -i "s/version \"[0-9.]*\"/version \"$version\"/g" "../Formula/coder.rb" + +# Update macOS ARM hash +sed -zi "s/sha256 \"[a-f0-9]*\"/sha256 \"$darwin_arm_sha\"/1" "../Formula/coder.rb" + +# Update macOS Intel hash +sed -zi "s/sha256 \"[a-f0-9]*\"/sha256 \"$darwin_intel_sha\"/2" "../Formula/coder.rb" + +# Update Linux hash +sed -zi "s/sha256 \"[a-f0-9]*\"/sha256 \"$linux_sha\"/3" "../Formula/coder.rb" From 19e640c59d9bcea4cb1b5290b961adf48c023f06 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 11:58:52 -0600 Subject: [PATCH 7/9] and fix comments --- ci/update-v1.sh | 3 +-- ci/update-v2.sh | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ci/update-v1.sh b/ci/update-v1.sh index a48a608..45751e1 100755 --- a/ci/update-v1.sh +++ b/ci/update-v1.sh @@ -1,7 +1,6 @@ #!/bin/bash -# Updates both the coder-cli and coder-cli-nightly formulae to have the given -# values. +# Updates the coder@1 formula # ./update.sh "" "" "" set -euo pipefail diff --git a/ci/update-v2.sh b/ci/update-v2.sh index b44eaf2..288312e 100755 --- a/ci/update-v2.sh +++ b/ci/update-v2.sh @@ -1,7 +1,6 @@ #!/bin/bash -# Updates both the coder-cli and coder-cli-nightly formulae to have the given -# values. +# Updates the coder formula # ./update.sh "" "" "" "" set -euo pipefail From ce151a75a499ee0f84f9846d5d20211a7cdca400 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 12:06:58 -0600 Subject: [PATCH 8/9] -> scripts/ --- {ci => scripts}/update-v1.sh | 0 {ci => scripts}/update-v2.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {ci => scripts}/update-v1.sh (100%) rename {ci => scripts}/update-v2.sh (100%) diff --git a/ci/update-v1.sh b/scripts/update-v1.sh similarity index 100% rename from ci/update-v1.sh rename to scripts/update-v1.sh diff --git a/ci/update-v2.sh b/scripts/update-v2.sh similarity index 100% rename from ci/update-v2.sh rename to scripts/update-v2.sh From d89f2bf00405ebdd4c0c185afe08adff7e997ace Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Tue, 29 Aug 2023 12:09:39 -0600 Subject: [PATCH 9/9] add concurrency workflow config --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e8eb997..b3feea8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,10 @@ on: pull_request: branches: ["**"] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: test: strategy: