Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logger fix with the github app auth method #53

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion acceptance/logs/expected.log
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ INFO: 📖 loading runway configuration
DEBUG: attempting to load config from acceptance/config/config.yml
INFO: ✅ loaded configuration successfully
INFO: 🚚 2 projects loaded
INFO: 🛫 starting runway - version: v0.5.0
INFO: 🛫 starting runway - version: v0.5.1
INFO: 📦 starting project project-1
INFO: 🕐 scheduling event with interval 3s for project-1
INFO: 📦 starting project project-2
Expand Down
4 changes: 3 additions & 1 deletion src/runway/services/github.cr
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ module Runway
protected def create_client(token : String?) : Octokit::Client | GitHubApp
if ENV["RUNWAY_GITHUB_APP_ID"]? && ENV["RUNWAY_GITHUB_APP_INSTALLATION_ID"]? && ENV["RUNWAY_GITHUB_APP_PRIVATE_KEY"]?
log_authentication_method("github app")
return GitHubApp.new.tap { rebuild_logger }
github_app = GitHubApp.new(@log)
rebuild_logger
return github_app
end

if token.nil? || token.empty?
Expand Down
9 changes: 8 additions & 1 deletion src/runway/services/github_app.cr
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class GitHubApp
@installation_id : Int32
@app_key : String

def initialize
def initialize(log : Log)
@log = log
@app_id = fetch_env_var("RUNWAY_GITHUB_APP_ID").to_i
@installation_id = fetch_env_var("RUNWAY_GITHUB_APP_INSTALLATION_ID").to_i
@app_key = fetch_env_var("RUNWAY_GITHUB_APP_PRIVATE_KEY").gsub(/\\+n/, "\n")
Expand Down Expand Up @@ -64,6 +65,12 @@ class GitHubApp
client.auto_paginate = ENV.fetch("OCTOKIT_CR_AUTO_PAGINATE", "true") == "true"
client.per_page = ENV.fetch("OCTOKIT_CR_PER_PAGE", "100").to_i
@token_refresh_time = Time.utc

# octokit.cr wipes out the loggers, so we need to re-apply them... bleh
# fetch the current log level
log_level = @log.level
@log = Runway.setup_logger(log_level.to_s.upcase)

client
end

Expand Down
2 changes: 1 addition & 1 deletion src/version.cr
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Runway
VERSION = "v0.5.0"
VERSION = "v0.5.1"
end
Loading