From 8c52937cae66c054213b278c5d5e0b84d7411e28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moln=C3=A1r=20Roland?= Date: Mon, 20 Jan 2025 16:42:18 +0100 Subject: [PATCH 1/8] Add GitHub workflows for automated testing and release. --- .gitlab/workflows/gem-publish.yml | 26 +++++++++++++++++++++++++ .gitlab/workflows/integration-test.yml | 27 ++++++++++++++++++++++++++ .gitlab/workflows/linting.yml | 22 +++++++++++++++++++++ .gitlab/workflows/unit-test.yml | 25 ++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 .gitlab/workflows/gem-publish.yml create mode 100644 .gitlab/workflows/integration-test.yml create mode 100644 .gitlab/workflows/linting.yml create mode 100644 .gitlab/workflows/unit-test.yml diff --git a/.gitlab/workflows/gem-publish.yml b/.gitlab/workflows/gem-publish.yml new file mode 100644 index 0000000..b05ae02 --- /dev/null +++ b/.gitlab/workflows/gem-publish.yml @@ -0,0 +1,26 @@ +name: Publish Ruby Gem + +on: + release: + types: [published] + +jobs: + push: + name: Push gem to RubyGems.org + runs-on: ubuntu-latest + + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag + + steps: + # Set up + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + ruby-version: ruby + + # Release + - uses: rubygems/release-gem@v1 diff --git a/.gitlab/workflows/integration-test.yml b/.gitlab/workflows/integration-test.yml new file mode 100644 index 0000000..1358f9d --- /dev/null +++ b/.gitlab/workflows/integration-test.yml @@ -0,0 +1,27 @@ +name: Integration Tests + +on: pull_request + +permissions: + contents: read + +jobs: + integration-test: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['3.1', '3.2', '3.3'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + run: bin/setup + - name: Run Gitlab Triage in dry-run on a real project + run: bundle exec gitlab-triage --dry-run --token $GITLAB_API_TOKEN --source project --source-id roland-release-management-playground --host-url https://gitlab.com --require 'support/triage_plugins.example.rb' --policies-file 'support/triage_policies.example.yml' + env: + GITLAB_API_TOKEN: "${{secrets.GITLAB_API_TOKEN}}" diff --git a/.gitlab/workflows/linting.yml b/.gitlab/workflows/linting.yml new file mode 100644 index 0000000..70fa25d --- /dev/null +++ b/.gitlab/workflows/linting.yml @@ -0,0 +1,22 @@ +name: Linting + +on: pull_request + +permissions: + contents: read + +jobs: + test: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + run: bin/setup + - name: Rubocop + run: rubocop -f github diff --git a/.gitlab/workflows/unit-test.yml b/.gitlab/workflows/unit-test.yml new file mode 100644 index 0000000..8262f1c --- /dev/null +++ b/.gitlab/workflows/unit-test.yml @@ -0,0 +1,25 @@ +name: Unit Tests + +on: pull_request + +permissions: + contents: read + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: ['3.1', '3.2', '3.3'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + run: bin/setup + - name: Run tests + run: bundle exec rake spec From 92457fcf0d82b249f33bed2de1772816a307a32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moln=C3=A1r=20Roland?= Date: Mon, 20 Jan 2025 16:59:54 +0100 Subject: [PATCH 2/8] Rename .gitlab folder to .github. --- {.gitlab => .github}/workflows/gem-publish.yml | 0 {.gitlab => .github}/workflows/integration-test.yml | 0 {.gitlab => .github}/workflows/linting.yml | 0 {.gitlab => .github}/workflows/unit-test.yml | 0 README.md | 7 +++---- lib/gitlab/triage/linear/migrator/issue_extension.rb | 4 ++-- 6 files changed, 5 insertions(+), 6 deletions(-) rename {.gitlab => .github}/workflows/gem-publish.yml (100%) rename {.gitlab => .github}/workflows/integration-test.yml (100%) rename {.gitlab => .github}/workflows/linting.yml (100%) rename {.gitlab => .github}/workflows/unit-test.yml (100%) diff --git a/.gitlab/workflows/gem-publish.yml b/.github/workflows/gem-publish.yml similarity index 100% rename from .gitlab/workflows/gem-publish.yml rename to .github/workflows/gem-publish.yml diff --git a/.gitlab/workflows/integration-test.yml b/.github/workflows/integration-test.yml similarity index 100% rename from .gitlab/workflows/integration-test.yml rename to .github/workflows/integration-test.yml diff --git a/.gitlab/workflows/linting.yml b/.github/workflows/linting.yml similarity index 100% rename from .gitlab/workflows/linting.yml rename to .github/workflows/linting.yml diff --git a/.gitlab/workflows/unit-test.yml b/.github/workflows/unit-test.yml similarity index 100% rename from .gitlab/workflows/unit-test.yml rename to .github/workflows/unit-test.yml diff --git a/README.md b/README.md index ac30218..4adceb8 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,8 @@ -

+

- +Upsun logo -

- +

Developer Center       Website       diff --git a/lib/gitlab/triage/linear/migrator/issue_extension.rb b/lib/gitlab/triage/linear/migrator/issue_extension.rb index 1b5755b..8334493 100644 --- a/lib/gitlab/triage/linear/migrator/issue_extension.rb +++ b/lib/gitlab/triage/linear/migrator/issue_extension.rb @@ -64,8 +64,8 @@ def process_comment(comment_body) end # @todo: make these configurable - LABEL_MIGRATION_FAILED = '/label ~"Linear::Migration Failed"' - LABEL_MIGRATED = '/label ~"Linear::Migrated"' + LABEL_MIGRATION_FAILED = '/label ~"Linear::Migration Failed"\n/remove_label ~"Linear::To Migrate"' + LABEL_MIGRATED = '/label ~"Linear::Migrated"\n/remove_label ~"Linear::Migration Failed" ~"Linear::To Migrate"' CLOSE_ACTON = "/close" def create_issue_in_linear(set_state: false, prepend_project_name: false, team_label_prefix: "Team") From 6f07b7d1336c4422dde6ac1636a8906b90f73cd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moln=C3=A1r=20Roland?= Date: Mon, 20 Jan 2025 17:05:22 +0100 Subject: [PATCH 3/8] Remove run command. --- .github/workflows/integration-test.yml | 1 - .github/workflows/linting.yml | 1 - .github/workflows/unit-test.yml | 1 - 3 files changed, 3 deletions(-) diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 1358f9d..f031115 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -20,7 +20,6 @@ jobs: with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically - run: bin/setup - name: Run Gitlab Triage in dry-run on a real project run: bundle exec gitlab-triage --dry-run --token $GITLAB_API_TOKEN --source project --source-id roland-release-management-playground --host-url https://gitlab.com --require 'support/triage_plugins.example.rb' --policies-file 'support/triage_policies.example.yml' env: diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 70fa25d..3c1cf72 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -17,6 +17,5 @@ jobs: with: ruby-version: '3.1' bundler-cache: true # runs 'bundle install' and caches installed gems automatically - run: bin/setup - name: Rubocop run: rubocop -f github diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 8262f1c..d7bb676 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -20,6 +20,5 @@ jobs: with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically - run: bin/setup - name: Run tests run: bundle exec rake spec From c8b0658875ef2c757d7c15aff76f0b20ff0387eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moln=C3=A1r=20Roland?= Date: Mon, 20 Jan 2025 17:13:24 +0100 Subject: [PATCH 4/8] Use bundle exec to run rubocop. --- .github/workflows/linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 3c1cf72..019c7ee 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -18,4 +18,4 @@ jobs: ruby-version: '3.1' bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Rubocop - run: rubocop -f github + run: bundle exec rubocop -f github From 2209c0f6b038a5037980d8aecb89803ef46a5a9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moln=C3=A1r=20Roland?= Date: Mon, 20 Jan 2025 17:56:53 +0100 Subject: [PATCH 5/8] Remove integration test as it involves too many external dependencies and complexity. --- .github/workflows/integration-test.yml | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 .github/workflows/integration-test.yml diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml deleted file mode 100644 index f031115..0000000 --- a/.github/workflows/integration-test.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Integration Tests - -on: pull_request - -permissions: - contents: read - -jobs: - integration-test: - - runs-on: ubuntu-latest - strategy: - matrix: - ruby-version: ['3.1', '3.2', '3.3'] - - steps: - - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - - name: Run Gitlab Triage in dry-run on a real project - run: bundle exec gitlab-triage --dry-run --token $GITLAB_API_TOKEN --source project --source-id roland-release-management-playground --host-url https://gitlab.com --require 'support/triage_plugins.example.rb' --policies-file 'support/triage_policies.example.yml' - env: - GITLAB_API_TOKEN: "${{secrets.GITLAB_API_TOKEN}}" From 657890b50db7a1d15e8f6642d503341b1deff183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moln=C3=A1r=20Roland?= Date: Mon, 20 Jan 2025 18:54:50 +0100 Subject: [PATCH 6/8] Testing GitHub CI unit tests and Rubocop --- spec/gitlab/triage/linear/migrator/graphql_client_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb b/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb index 727eaf0..7a656b4 100644 --- a/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb +++ b/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb @@ -29,6 +29,12 @@ it "returns the cached result" do expect(client.query(query_string, variables)).to eq("cached result") end + + ## Testing GitHub CI unit tests and Rubocop... + it "fails" do + expect(false).to eq(true) # this also will violate Rubocop rules. + end + end context "when the query is not in the cache" do From e5e53650ace9ee426c0b2515154f4a02d4580cfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moln=C3=A1r=20Roland?= Date: Mon, 20 Jan 2025 18:56:27 +0100 Subject: [PATCH 7/8] Revert previous change. CI should be green again. --- spec/gitlab/triage/linear/migrator/graphql_client_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb b/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb index 7a656b4..fa4b83d 100644 --- a/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb +++ b/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb @@ -30,11 +30,6 @@ expect(client.query(query_string, variables)).to eq("cached result") end - ## Testing GitHub CI unit tests and Rubocop... - it "fails" do - expect(false).to eq(true) # this also will violate Rubocop rules. - end - end context "when the query is not in the cache" do From 4b363405eebacd2012cfa6533369429f906ea5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moln=C3=A1r=20Roland?= Date: Mon, 20 Jan 2025 18:57:49 +0100 Subject: [PATCH 8/8] Fix Rubocop. --- spec/gitlab/triage/linear/migrator/graphql_client_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb b/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb index fa4b83d..727eaf0 100644 --- a/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb +++ b/spec/gitlab/triage/linear/migrator/graphql_client_spec.rb @@ -29,7 +29,6 @@ it "returns the cached result" do expect(client.query(query_string, variables)).to eq("cached result") end - end context "when the query is not in the cache" do