View | Details | Raw Unified | Return to bug 39877
Collapse All | Expand All

(-)a/Koha/Devel/CI/IncrementalRuns.pm (-6 / +10 lines)
Lines 84-89 sub new { Link Here
84
    };
84
    };
85
85
86
    if ( $self->{incremental_run} ) {
86
    if ( $self->{incremental_run} ) {
87
88
        die "Cannot use increment runs if `KOHA_IMAGE` environment variable is not set" unless $ENV{KOHA_IMAGE};
89
87
        unless ( $self->{test_name} ) {
90
        unless ( $self->{test_name} ) {
88
            my @caller_info     = caller();
91
            my @caller_info     = caller();
89
            my $script_filename = $caller_info[1];
92
            my $script_filename = $caller_info[1];
Lines 92-104 sub new { Link Here
92
            $self->{test_name} =~ s|\..*$||g;
95
            $self->{test_name} =~ s|\..*$||g;
93
        }
96
        }
94
97
98
        $self->{test_dir} = $args->{git_repo_dir} . '/' . $ENV{KOHA_IMAGE} . '/' . $args->{test_name};
99
95
        if ( $self->{git_repo_dir} && $self->{repo_url} ) {
100
        if ( $self->{git_repo_dir} && $self->{repo_url} ) {
96
            unless ( -d $self->{git_repo_dir} ) {
101
            unless ( -d $self->{git_repo_dir} ) {
97
                qx{git clone $self->{repo_url} $self->{git_repo_dir}};
102
                qx{git clone $self->{repo_url} $self->{git_repo_dir}};
98
            }
103
            }
99
            qx{git -C $self->{git_repo_dir} fetch origin};
104
            qx{git -C $self->{git_repo_dir} fetch origin};
100
105
101
            make_path("$self->{git_repo_dir}/$self->{test_name}");
106
            make_path("$self->{git_repo_dir}/$self->{test_dir}");
102
        }
107
        }
103
    }
108
    }
104
109
Lines 122-128 sub get_files_to_test { Link Here
122
    my $no_history;
127
    my $no_history;
123
    if ( $self->{incremental_run} ) {
128
    if ( $self->{incremental_run} ) {
124
        my @koha_commit_history   = qx{git log --pretty=format:"%h"};
129
        my @koha_commit_history   = qx{git log --pretty=format:"%h"};
125
        my @tested_commit_history = qx{ls $self->{git_repo_dir}/$self->{test_name}};
130
        my @tested_commit_history = qx{ls $self->{git_repo_dir}/$self->{test_die}};
126
        chomp for @koha_commit_history, @tested_commit_history;
131
        chomp for @koha_commit_history, @tested_commit_history;
127
        if (@tested_commit_history) {
132
        if (@tested_commit_history) {
128
            my $last_build_commit = firstval {
133
            my $last_build_commit = firstval {
Lines 131-137 sub get_files_to_test { Link Here
131
            }
136
            }
132
            @koha_commit_history;
137
            @koha_commit_history;
133
            if ($last_build_commit) {
138
            if ($last_build_commit) {
134
                @files = @{ from_json( read_file("$self->{git_repo_dir}/$self->{test_name}/$last_build_commit") ) };
139
                @files = @{ from_json( read_file("$self->{git_repo_dir}/$self->{test_dir}/$last_build_commit") ) };
135
                push @files, $dev_files->ls_files( $filetype, "$last_build_commit HEAD" );
140
                push @files, $dev_files->ls_files( $filetype, "$last_build_commit HEAD" );
136
            } else {
141
            } else {
137
142
Lines 164-170 sub report_results { Link Here
164
    my $commit_id = qx{git rev-parse --short HEAD};
169
    my $commit_id = qx{git rev-parse --short HEAD};
165
    chomp $commit_id;
170
    chomp $commit_id;
166
171
167
    my $failure_file = "$self->{git_repo_dir}/$self->{test_name}/$commit_id";
172
    my $failure_file = "$self->{git_repo_dir}/$self->{test_dir}/$commit_id";
168
    my $failures     = [
173
    my $failures     = [
169
        sort map {
174
        sort map {
170
            my ( $file, $exit_code ) = ( $_, $results->{$_} );
175
            my ( $file, $exit_code ) = ( $_, $results->{$_} );
Lines 175-181 sub report_results { Link Here
175
    write_file( $failure_file, to_json($failures) );
180
    write_file( $failure_file, to_json($failures) );
176
181
177
    qx{git -C $self->{git_repo_dir} add $failure_file};
182
    qx{git -C $self->{git_repo_dir} add $failure_file};
178
    qx{git -C $self->{git_repo_dir} commit -m "$commit_id - $self->{test_name}"};
183
    qx{git -C $self->{git_repo_dir} commit -m "$commit_id - $self->{test_dir}"};
179
    ( my $push_domain = $self->{repo_url} ) =~ s{^https://}{};
184
    ( my $push_domain = $self->{repo_url} ) =~ s{^https://}{};
180
    my $push_url = "https://gitlab-ci-token:$self->{token}\@$push_domain";
185
    my $push_url = "https://gitlab-ci-token:$self->{token}\@$push_domain";
181
    qx{git -C $self->{git_repo_dir} push $push_url main};
186
    qx{git -C $self->{git_repo_dir} push $push_url main};
182
- 

Return to bug 39877