TruCol / Self-host-GitLab-CI-for-GitHub

Installs your own GitLab CI and runs it on all your GitHub repos, in a single command.
GNU Affero General Public License v3.0
4 stars 3 forks source link

Write method that removes commits from evaluated lists if no build_txt is available. #130

Closed a-t-0 closed 1 year ago

a-t-0 commented 1 year ago

There may still be some commit sha's in the EVALUATED_COMMITS_WITH_CI_LIST_FILENAME=evaluated_commits_with_ci.txt EVALUATED_COMMIT_WITH_ERROR_LIST_FILENAME=unsuccessfull_ci_commits.txt lists, that are not actually accompanied by a build status .txt file.

Make it analog to:

delete_invalid_commit_txts(){
    manual_assert_dir_exists "$MIRROR_LOCATION/GitHub/$GITHUB_STATUS_WEBSITE_GLOBAL"

    # The */*/*/*.txt adheres to:
    #$organisation/$github_repo_name/$github_branch_name/$commit_sha.txt"
    for build_status_txt in "$MIRROR_LOCATION/GitHub/$GITHUB_STATUS_WEBSITE_GLOBAL/"*/*/*/*.txt; do
        if [ "$(commit_build_txt_is_valid "$build_status_txt")" != "FOUND" ]; then

            # Extract the commit sha from the build status filepath.
            start=$((${#build_status_txt} - 44))
            commit_sha=${build_status_txt:$start:40}
            # Verify the commit_sha length.
            if [ "${#commit_sha}" != 40 ]; then
                echo "Error, the commit sha does not have length 40:"
                echo "$commit_sha"
                echo "$build_status_txt"
                exit 5
            fi

            # Remove commit from evaluated list.
            delete_lines_containing_substring_from_file $commit_sha "$MIRROR_LOCATION/GitHub/$GITHUB_STATUS_WEBSITE_GLOBAL/$EVALUATED_COMMITS_LIST_FILENAME"
            # Remove commit from evaluated with GitLab CI yml list.
            delete_lines_containing_substring_from_file $commit_sha "$MIRROR_LOCATION/GitHub/$GITHUB_STATUS_WEBSITE_GLOBAL/$EVALUATED_COMMITS_WITH_CI_LIST_FILENAME"
            # Add to errored list.
            add_commit_sha_to_evaluated_list $commit_sha $EVALUATED_COMMIT_WITH_ERROR_LIST_FILENAME

            # Delete build status txt file and verify it is deleted.
            rm "$build_status_txt"
            manual_assert_file_does_not_exists "$build_status_txt"
        fi
    done
}
a-t-0 commented 1 year ago

Done.