Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #403 from joao-paulo-parity/fix
Browse files Browse the repository at this point in the history
fix CI
  • Loading branch information
mordamax authored Dec 6, 2022
2 parents 65a304c + 5df3ed4 commit dc40e05
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 53 deletions.
14 changes: 12 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
variables:
KUBE_NAMESPACE: "processbot"
CI_REGISTRY: "paritytech"
BUILDAH_IMAGE: "quay.io/buildah/stable:v1.27"
CI_IMAGE: "paritytech/ci-linux:production"
GIT_STRATEGY: fetch
GIT_DEPTH: 3
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
GITHUB_ORGANIZATION: "paritytech"
GITLAB_URL: https://gitlab.parity.io

default:
image: paritytech/ci-linux:production
image: $CI_IMAGE
interruptible: true
retry:
max: 2
when:
Expand All @@ -25,10 +28,15 @@ stages:
- dockerize
- deploy

.test-refs:
rules:
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs

#### stage: check

check:
stage: check
extends: .test-refs
script:
- cargo +nightly fmt --all -- --check
- cargo check --all-targets --workspace
Expand All @@ -38,11 +46,13 @@ check:

integration-tests:
stage: test
extends: .test-refs
script:
- ./scripts/run_integration_tests.sh

tests:
stage: test
extends: .test-refs
script:
- cargo test --lib

Expand All @@ -65,7 +75,7 @@ build:
#### stage: dockerize

.build_and_push: &build_and_push
image: quay.io/buildah/stable
image: $BUILDAH_IMAGE
variables:
GIT_STRATEGY: none
DOCKER_IMAGE: "${CI_REGISTRY}/${KUBE_NAMESPACE}"
Expand Down
13 changes: 8 additions & 5 deletions helm/templates/processbot-ingress.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Ingress for the webhook
apiVersion: extensions/v1beta1
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: processbot-ingress
Expand All @@ -14,10 +14,13 @@ spec:
- host: {{ .Values.ingress.domain }}
http:
paths:
- path: /
backend:
serviceName: parity-processbot
servicePort: {{ .Values.app.WEBHOOK_PORT }}
- backend:
service:
name: parity-processbot
port:
number: {{ .Values.app.WEBHOOK_PORT }}
path: /
pathType: ImplementationSpecific
tls:
- hosts:
- {{ .Values.ingress.domain }}
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub struct PullRequestDetails {
pub number: i64,
}

#[derive(PartialEq, Debug, Clone)]
#[derive(PartialEq, Eq, Debug, Clone)]
pub struct PullRequestDetailsWithHtmlUrl {
pub html_url: String,
pub owner: String,
Expand Down
6 changes: 2 additions & 4 deletions src/github/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,13 +285,11 @@ impl GithubClient {
I: Into<Cow<'b, str>> + Clone,
T: serde::de::DeserializeOwned + core::fmt::Debug,
{
let res = self
.get_response(url, serde_json::json!({}))
self.get_response(url, serde_json::json!({}))
.await?
.json::<T>()
.await
.context(error::Http);
res
.context(error::Http)
}

pub async fn get_status<'b, I>(&self, url: I) -> Result<u16>
Expand Down
50 changes: 25 additions & 25 deletions src/github/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait HasPullRequestDetails {
fn get_pull_request_details(&self) -> Option<PullRequestDetails>;
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubPullRequest {
pub url: String,
pub html_url: String,
Expand Down Expand Up @@ -47,42 +47,42 @@ impl GithubPullRequest {
}
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubFileContents {
pub content: String,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubPullRequestBase {
#[serde(rename = "ref")]
pub ref_field: String,
pub repo: GithubPullRequestBaseRepository,
}

#[derive(PartialEq, Clone, Debug, Serialize, Deserialize)]
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
pub enum GithubUserType {
User,
Bot,
#[serde(other)]
Unknown,
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
pub struct GithubUser {
pub login: String,
#[serde(rename = "type")]
pub type_field: GithubUserType,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubRepository {
pub name: String,
pub full_name: String,
pub owner: GithubUser,
pub html_url: String,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubCommitStatus {
pub id: i64,
pub context: String,
Expand All @@ -91,7 +91,7 @@ pub struct GithubCommitStatus {
pub target_url: Option<String>,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum GithubCommitStatusState {
Success,
Expand All @@ -101,68 +101,68 @@ pub enum GithubCommitStatusState {
Unknown,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubInstallation {
pub id: i64,
pub account: GithubUser,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubInstallationToken {
pub token: String,
pub expires_at: Option<String>,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum GithubIssueCommentAction {
Created,
#[serde(other)]
Unknown,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubCheckRuns {
pub check_runs: Vec<GithubCheckRun>,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubPullRequestHeadRepository {
pub name: String,
pub owner: GithubUser,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubPullRequestHead {
pub sha: String,
pub repo: GithubPullRequestHeadRepository,
#[serde(rename = "ref")]
pub ref_field: String,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubPullRequestBaseRepository {
pub name: String,
pub owner: GithubUser,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum GithubCheckRunConclusion {
Success,
#[serde(other)]
Unknown,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum GithubCheckRunStatus {
Completed,
#[serde(other)]
Unknown,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct GithubCheckRun {
pub id: i64,
pub name: String,
Expand All @@ -171,7 +171,7 @@ pub struct GithubCheckRun {
pub head_sha: String,
}

#[derive(Debug, PartialEq, Deserialize)]
#[derive(Debug, PartialEq, Eq, Deserialize)]
pub struct GithubIssue {
pub number: i64,
pub html_url: String,
Expand All @@ -183,33 +183,33 @@ impl HasPullRequestDetails for GithubIssue {
}
}

#[derive(PartialEq, Deserialize)]
#[derive(PartialEq, Eq, Deserialize)]
pub struct GithubIssueComment {
pub id: i64,
pub body: String,
pub user: GithubUser,
}

#[derive(Debug, PartialEq, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum GithubWorkflowJobConclusion {
#[serde(other)]
Unknown,
}

#[derive(PartialEq, Deserialize)]
#[derive(PartialEq, Eq, Deserialize)]
pub struct GithubWorkflowJob {
pub head_sha: String,
pub conclusion: Option<GithubWorkflowJobConclusion>,
}

#[derive(Deserialize, PartialEq)]
#[derive(Deserialize, PartialEq, Eq)]
pub struct GithubIssueRepository {
pub owner: GithubUser,
pub name: String,
}

#[derive(PartialEq, Deserialize)]
#[derive(PartialEq, Eq, Deserialize)]
#[serde(untagged)]
pub enum GithubWebhookPayload {
IssueComment {
Expand Down Expand Up @@ -363,7 +363,7 @@ fn parse_pull_request_details_from_url(
fn parse_repository_full_name(full_name: &str) -> Option<(String, String)> {
let parts: Vec<&str> = full_name.split('/').collect();
parts
.get(0)
.first()
.and_then(|owner| {
parts.get(1).map(|repo_name| {
Some((owner.to_string(), repo_name.to_string()))
Expand Down
2 changes: 1 addition & 1 deletion src/gitlab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl MainConfig {
}
}

#[derive(Deserialize, PartialEq, Debug)]
#[derive(Deserialize, PartialEq, Eq, Debug)]
#[serde(rename_all = "snake_case")]
pub enum GitlabPipelineStatus {
Created,
Expand Down
6 changes: 3 additions & 3 deletions src/merge_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub async fn cleanup_merge_request(
&& dependency.repo == repo && dependency.number
== number
{
related_dependents.insert((&mr.sha).clone(), mr);
related_dependents.insert(mr.sha.clone(), mr);
continue 'to_next_db_item;
}
}
Expand Down Expand Up @@ -473,11 +473,11 @@ pub async fn check_merge_is_allowed(
log::info!("{} is mergeable", pr.html_url);
}

return check_all_companions_are_mergeable(
check_all_companions_are_mergeable(
state,
pr,
requested_by,
companion_reference_trail,
)
.await;
.await
}
4 changes: 2 additions & 2 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use tokio::process::Command;

use crate::{error::*, types::Result};

#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
pub struct CommandMessageConfiguration<'a, Secret: AsRef<str>> {
pub secrets_to_hide: Option<&'a [Secret]>,
pub are_errors_silenced: bool,
}

#[derive(PartialEq)]
#[derive(PartialEq, Eq)]
pub enum CommandMessage<'a, Secret: AsRef<str>> {
Configured(CommandMessageConfiguration<'a, Secret>),
}
Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ use crate::error::Error;

pub type Result<T, E = Error> = std::result::Result<T, E>;

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PlaceholderDeserializationItem {}
8 changes: 1 addition & 7 deletions tests/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ pub mod setup;
use cmd::exec;

pub fn get_available_port() -> Option<u16> {
for port in 1025..65535 {
if TcpListener::bind(("127.0.0.1", port)).is_ok() {
return Some(port);
}
}

None
(1025..65535).find(|&port| TcpListener::bind(("127.0.0.1", port)).is_ok())
}

pub fn read_snapshot(log_dir: PathBuf, texts_to_hide: &[&str]) -> String {
Expand Down
4 changes: 2 additions & 2 deletions tests/helpers/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn common_setup() -> CommonSetupOutput {
.unwrap()
.log_to_file(
FileSpec::default()
.directory((&log_dir).path().to_path_buf())
.directory(log_dir.path().to_path_buf())
.basename("test")
.suppress_timestamp()
.suffix("log"),
Expand Down Expand Up @@ -66,7 +66,7 @@ pub fn common_setup() -> CommonSetupOutput {
.arg("--export-all")
.arg("--enable=receive-pack")
.stdout(Stdio::null())
.current_dir((&git_daemon_dir).path())
.current_dir(git_daemon_dir.path())
.spawn()
.unwrap();

Expand Down

0 comments on commit dc40e05

Please sign in to comment.