From dc0af9b56fca7b37da683579986fbcb124b3fa19 Mon Sep 17 00:00:00 2001 From: Matt Boris Date: Wed, 3 Aug 2022 10:48:47 -0400 Subject: [PATCH] feat(ci): connect repo to Community-TC --- .git-template/hooks/pre-commit | 5 +++ .pre-commit-config.yaml | 21 +++++++++++ .rubocop.yml | 5 +++ .taskcluster.yml | 67 ++++++++++++++++++++++++++++++++++ Formula/taskcluster.rb | 15 +++++--- Gemfile | 5 +++ Gemfile.lock | 34 +++++++++++++++++ 7 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 .git-template/hooks/pre-commit create mode 100644 .pre-commit-config.yaml create mode 100644 .rubocop.yml create mode 100644 .taskcluster.yml create mode 100644 Gemfile create mode 100644 Gemfile.lock diff --git a/.git-template/hooks/pre-commit b/.git-template/hooks/pre-commit new file mode 100644 index 0000000..6d8d24a --- /dev/null +++ b/.git-template/hooks/pre-commit @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +if [ -f .pre-commit-config.yaml ]; then + echo 'pre-commit configuration detected, but `pre-commit install` was never run' 1>&2 + exit 1 +fi diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..66e90d9 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + # Trims trailing whitespace + - id: trailing-whitespace + # Makes sure files end in a newline and only a newline + - id: end-of-file-fixer + # Check for files that contain merge conflict strings + - id: check-merge-conflict + +- repo: https://github.com/marco-c/taskcluster_yml_validator + rev: v0.0.9 + hooks: + # Validates .taskcluster.yml file against possible GitHub events + - id: taskcluster_yml + +ci: + skip: [taskcluster_yml] diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..36cd25f --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,5 @@ +Style/StringLiterals: + Enabled: false + +AllCops: + NewCops: enable diff --git a/.taskcluster.yml b/.taskcluster.yml new file mode 100644 index 0000000..ff11e2c --- /dev/null +++ b/.taskcluster.yml @@ -0,0 +1,67 @@ +version: 1 +reporting: checks-v1 +policy: + pullRequests: public +tasks: + $let: + head_rev: + $if: tasks_for == "github-pull-request" + then: ${event.pull_request.head.sha} + else: ${event.after} + repository: + $if: tasks_for == "github-pull-request" + then: ${event.pull_request.head.repo.html_url} + else: ${event.repository.html_url} + in: + $let: + tests: + - image: ruby:alpine + name: lint with RuboCop + command: + - /bin/sh + - '--login' + - '-c' + - >- + git clone ${repository} repo && + cd repo && + git config advice.detachedHead false && + git checkout ${head_rev} && + bundle install && + rubocop + - image: homebrew/brew + name: brew {audit, test, install} + command: + - /bin/bash + - '--login' + - '-c' + - >- + git clone ${repository} repo && + cd repo && + git config advice.detachedHead false && + git checkout ${head_rev} && + brew audit --strict ./Formula/taskcluster.rb && + brew test ./Formula/taskcluster.rb && + brew install ./Formula/taskcluster.rb + in: + $let: + test_tasks: + $map: {$eval: tests} + each(test): + taskId: {$eval: as_slugid(test.name)} + taskQueueId: proj-taskcluster/ci + created: {$fromNow: ''} + deadline: {$fromNow: '1 hour'} + payload: + maxRunTime: 3600 + image: ${test.image} + command: {$eval: 'test.command'} + metadata: + name: ${test.name} + description: ${test.name} + owner: taskcluster-internal@mozilla.com + source: ${repository} + in: + $flattenDeep: + $match: + (tasks_for == "github-pull-request" && event["action"] in ["opened","reopened","synchronize"]): + {$eval: test_tasks} diff --git a/Formula/taskcluster.rb b/Formula/taskcluster.rb index bfc953a..f489e13 100644 --- a/Formula/taskcluster.rb +++ b/Formula/taskcluster.rb @@ -1,19 +1,22 @@ +# frozen_string_literal: true + +# Homebrew formula for taskcluster CLI class Taskcluster < Formula - desc "A Taskcluster client library for the command line" + desc "Client library for the Taskcluster CLI" homepage "https://github.com/taskcluster/taskcluster/tree/main/clients/client-shell" - version "v44.17.2" + version "44.17.2" license "MPL-2.0" if OS.mac? if Hardware::CPU.physical_cpu_arm64? - url "https://github.com/taskcluster/taskcluster/releases/download/#{version}/taskcluster-darwin-arm64", :using => :curl + url "https://github.com/taskcluster/taskcluster/releases/download/v#{version}/taskcluster-darwin-arm64" sha256 "1ccf56972988f45c88e9a21a536728f1064eabef49a9d085e16ac41db14214a5" else - url "https://github.com/taskcluster/taskcluster/releases/download/#{version}/taskcluster-darwin-amd64", :using => :curl + url "https://github.com/taskcluster/taskcluster/releases/download/v#{version}/taskcluster-darwin-amd64" sha256 "7897baf6c27350e5a6fe46e93f9bb4890f5dd98a117196acfb4267e639624a5c" end elsif OS.linux? - url "https://github.com/taskcluster/taskcluster/releases/download/#{version}/taskcluster-linux-amd64", :using => :curl + url "https://github.com/taskcluster/taskcluster/releases/download/v#{version}/taskcluster-linux-amd64" sha256 "d12b40c048e96bd5376f9d28c4831075ee6b74b3c8b9bd3d85f57cc1a9ec1971" end @@ -30,6 +33,6 @@ def install end test do - system "#{bin}/taskcluster --help" + system "#{bin}/taskcluster", "--help" end end diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..6b3dbe4 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +gem 'rubocop', require: false diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..2b533f7 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,34 @@ +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.2) + json (2.6.2) + parallel (1.22.1) + parser (3.1.2.0) + ast (~> 2.4.1) + rainbow (3.1.1) + regexp_parser (2.5.0) + rexml (3.2.5) + rubocop (1.32.0) + json (~> 2.3) + parallel (~> 1.10) + parser (>= 3.1.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.19.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.19.1) + parser (>= 3.1.1.0) + ruby-progressbar (1.11.0) + unicode-display_width (2.2.0) + +PLATFORMS + arm64-darwin-21 + +DEPENDENCIES + rubocop + +BUNDLED WITH + 2.3.11