I came up an interesting situation recently and I couldn't find something on that, so maybe someone who knows can share this info.
We have a github repository in a github organization. This has a set of GHA jobs (eg release.yaml) which are supposed to run on github shared runners:
runs-on: ubuntu-latest
The jobs were picked up fine, until I added a job that I wanted to run it on a self-hosted runner:
runs-on: self-hosted
So I registered the self-hosted runner, the latter job got picked up just fine.
But when I came back to run one of the 1st stage jobs (ie release.yaml), the job wasn't getting picked up by the github shared runner as it is supposed to by the code, but was getting queued and waiting for a self-hosted runner to be available.
Has anyone seen this before? Is it standard behaviour or I should commit an issue with github?
PS: Deregistering the self-hosted runner from repository settings resolved the issue, but still, does this mean we can't have a set of jobs that some use self-hosted and some use github-shared runners?
Related
I'm working in a company that uses Github Actions and Argocd.(using argocd helm chart).
Needless to say that the Github repo is private and argocd is in an internal network that used by the company only.
The flow of what we want to do is that when we deploy the app and the deployment succeeded - Trigger another workflow that will run tests on the deployed environment.
Basically, the deployment will be the trigger for another workflow.
I have been trying to configure webhook from argocd to github but with no success.
What is the best approach to this situation, will be happy to provide more context if needed.
Edit:
The test workflow i'm trying to use workflow_dispatch.
name: workflow_02
on:
push:
branches: [ argo-github-trigger ]
workflow_dispatch:
jobs:
log-the-inputs:
runs-on: ubuntu-latest
steps:
- run: |
echo "Worked"
I'm expecting to see a "Run workflow" button on github but it doesn't appear. On another repo, that I have Admin priviliges and can work on the main branch, I tried the same workflow and it worked.
The best approach would be to use a post sync hook.
Why is it necessary to run the tests in a GitHub actions workflow? Since the application is already deployed to the cluster, wouldn't it make more sense to run the tests directly on the cluster, instead of going through the trouble of communicating with Github?
We have Vercel preview deployments setup for every pull request in Github.
On every pull request the code gets deployed to a Vercel test / acc / prod environment which are coupled to different backends.
For every pull request we want to run some (Cypress) tests against it, but only against the Vercel test environment.
We have this working by using the deployment_status event and specifying it should only run when the environment is test.
jobs:
cypress:
if: github.event.deployment_status.environment == 'Preview – Test'
This will result in a skipped Github run for acc / prod and a pass/fail for the test environment.
However Github only lists the last run in the PR Github checks, this can be either the skipped or the pass/fail run and is depending on which preview environment gets deployed last.
Is there a way to enforce that Github only lists the relevant run?
I tried making that run dynamic and making the test one mandatory but the check still get's overridden if test was not the last deployed Vercel environment.
I would like to run a yaml pipeline from one project. I have a task in my yaml to scan all the source code. Using this Yaml I would like to scan all the source code in master branch for all the project and all the repository inside the same Org.
How can I get all the repo for all the project and iterate? Can someone help me ?
test.yaml
repositories:
- repository: justAnotherName
type: github
name: myGitRepo
endpoint: myGitServiceConnection
trigger:
branches:
include:
- master
steps:
- task: CredScan#2
inputs:
toolMajorVersion: 'V2'
outputFormat: 'tsv'
scanFolder: '$(Build.SourcesDirectory)'
If you're looking to pull every repo within a project, you have one of two options (see below). However, I'd advise caution before attempting this on a Microsoft-hosted agent, they have a 60-minute timeout by default. If you're using a self-hosted agent, you need not worry. I'd still advise breaking this up to avoid creating a long-running release that also consumes a large amount of disk space with each run.
https://learn.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#timeouts
That being said, here are the options you have:
Option 1 (Not the best)
Manually add a repository: dependency for every project and a checkout: task for every repo within the projects.
This is heavily manual and would require maintenance every time a report is added.
Option 2
You can write a custom PowerShell/bash script that uses the Azure DevOps API and git to automatically scan all projects and repos within the org and pull them onto the machine.
Start by issuing a request to get all of the projects within the org:
https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/list?view=azure-devops-rest-6.0
Then, iterate through every project and get all repos:
https://learn.microsoft.com/en-us/rest/api/azure/devops/git/repositories/list?view=azure-devops-rest-6.0
Finally, iterate through each repo and run git clone [repository URL] to clone it onto the build agent.
NOTE: You will want to ensure to have a lot of free disk space on the agent machine and that you clean up the build space after this operation.
I'm trying to use GitHub to trigger on PR a GitLab pipeline.
Practically when a developer creates a PR in GitHub, his/her code get tested against a GitLab pipeline.
I'm trying to follow this user guide: https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/github_integration.html
and we have a silver account, but it won't work. When creating the PR, the GitLab pipeline is not triggered.
Anyone with this kind of experience who can help?
Thanks
Joe
I've found the cause of the issue.
In order for GitHub to trigger GitLab as CD/CI mostly in PR request, you need to have a Silver/Premium account AND, very important, being the root owner.
Any other case, you won't be able to see github in the integration list on GitLab. People from gitlab had the brilliant idea to hide it instead of showing it disabled (which would had been a tip to understand that you needed an upgraded license)
In the video above it's not explained.
Firstly, you need to give us the content of your .gitlab-ci.yaml file. In your question you asked about GitHub but you're following Gitlab documentation which is completely different. Both are using git commands to commit and push repos but Github & Gitlab are different.
For Github pipelines, you need to create a repository, then you go to Actions. Github will propose you to configure a .github/workflows directory which contain a file.yaml. In this .yaml file you can code your pipelines. According to your project, Github will propose you several linux machines with the adequate configuration to run your files (If it's a Java Project --> you'll be proposed maven machines, Python --> Python Machines, React/Angular -> machines with npm installed, Docker, Kubernetes for deployments...) and you're limited to 4 private project as far as I know (check this last information).
For Gitlab you have two options, you can use preconfigured machines like github, and you call them by adding for example atag: npm in your .gitlab-ci.yaml file, to call a machine with npm installed, but you need to pay an amount of money. Or you can configure your own runners by following the Gitlab documentation with gitlab commands (which is the best option), but you'll need good machines and servers to run npm - mvn - python3 - ... commands
Of course, in your Gitlab repository, and finally to answer your question this an example, of .gitlab-ci.yaml file with two simple stages: build & test, the only statement specifies that these pipelines will run if there is a merge request ( I use the preconfigured machines of Gitlab as a sample here) More details on my python github project https://github.com/mehdimaaref7/Scrapping-Sentiment-Analysis and for gitlab https://docs.gitlab.com/runner/
stages:
- build
- test
build:
tags:
- shell
- linux
stage: build
script:
- echo "Building"
- mkdir build
- touch build/info.txt
artifacts:
paths:
- build/
only:
- merge_requests
test:
tags:
- shell
- linux
stage: test
script:
- echo "Testing"
- test -f "build/info.txt"
only:
- merge_requests
My question is relatively simple,
I have gitlab set-up, gitlab CI too and two separate server which each have their own runner.
Both runners are working and can execute a build successfully.
What I'd like to achieve now is to have one project be build by both runners, perferrably even with seperate commands. This last thing doesn't seem possible however if I add both runners to a project it just seems to build on one of them and not the other.
Is it possible to get it to build on both and maybe even vary the scripts?
Someone brought this up on the GitLab CI issue tracker (https://gitlab.com/gitlab-org/gitlab-ci/issues/237). The workaround proposed there is as follows:
Create multiple jobs with different tags and assign different tags to these runners:
job1:
script: echo 1
tags:
- runner1
job2:
script: echo 2
tags:
- runner2
Not a great solution, especially if you want to run the exact same job on a bunch of runners (as I do), but it can be made to work.