How to run cron jobs in github action for a particular day and time - cypress

How to run cron jobs automatically every Thursday at 10:30 am Australian Standard time irrespective of any other action? I have tried the below, but not sure if it's running. Could someone please advise?
I have the schedule.yml file in my branch.
Should I add the schedule.yml somewhere else?
Branch: cypress-schedule-test-ci-100
.github\workflows\schedule.yml
name: Cypress E2E Tests
on:
schedule:
- cron: "30 10 * * 4"
env:
CYPRESS_BOOKING_PASSWORD: ${{ secrets.CYPRESS_BOOKING_PASSWORD }}
CYPRESS_BOOKING_FREE_USER_PASSWORD: ${{ secrets.CYPRESS_BOOKING_FREE_USER_PASSWORD }}
jobs:
install:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Install dependencies
uses: cypress-io/github-action#v2
with:
# just perform install
runTests: false
tests:
runs-on: ubuntu-22.04
needs: install
steps:
- name: Check out code
uses: actions/checkout#v2
- name: Install dependencies
uses: cypress-io/github-action#v2
with:
# perform installation
runTests: false
- name: Run E2E tests
run: npm run cy:run -- --env grepTags="#MainUITests+-#Failing",ENV="qaserver" --browser chrome
- name: Upload Results
uses: actions/upload-artifact#v3
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
- uses: actions/upload-artifact#v2
if: always()
with:
name: cypress-videos
path: cypress/videos

While working with the schedule cron job, the following points need to keep in mind:
You can schedule a workflow to run at specific UTC times using POSIX cron syntax.
So, you might need to adjust it according to your time zone.
Scheduled workflows run on the latest commit on the default or base branch.
It should be scheduled for the default branch e.g. main. Apparently, this seems to be the reason why your scheduled job isn't working.
And,
Note: The schedule event can be delayed during periods of high loads of GitHub Actions workflow runs. High load times include the start of every hour. To decrease the chance of delay, schedule your workflow to run at a different time of the hour.
You need to account for such delays due to high loads.

Related

Run firebase emulators + vitest at once

The bounty expires in 7 days. Answers to this question are eligible for a +100 reputation bounty.
ARNON wants to draw more attention to this question:
What should I do to make it work? > I would like to run job 2 as soon as the emulator ports are open and finish job 1 only after job 2 finishes.
I'm trying to run two jobs at the same time.
First I need to run firebase emulators and when the ports are open, I need to run vitest.
This is what I'm doing at the moment:
name: Run Tests
on:
pull_request:
branches: [develop]
workflow_dispatch:
jobs:
job1:
name: Run Emulator
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Use Node.js 18.14.0
uses: actions/setup-node#v3
with:
node-version: 18.14.0
cache: 'npm'
- name: Execute Emulator
env:
VITE_RELEASE_STAGE: testing
run: |
npm ci
npm install --save firebase-tools
npm run emulators
job2:
name: Run Unit Tests
needs: job1
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: Use Node.js 18.14.0
uses: actions/setup-node#v3
with:
node-version: 18.14.0
cache: 'npm'
- name: Execute Unit Tests
env:
VITE_RELEASE_STAGE: testing
run: |
npm ci
npm run test
The doors open perfectly, but the second job never runs.
Here lies my doubt. Because if I don't use needs the two will run at the same time and I will get an error in job2 because the ports will not be open in job 1.
I would like to run job 2 as soon as the emulator ports are open and finish job 1 only after job 2 finishes.
Does anyone know how I can resolve this?
EDIT
These are the two executed scripts that are in my package.json:
"test": "vitest",
"emulators": "firebase emulators:start --project celebrityfanalizer --import emulatorData"

Can't checkout the same repo multiple times in a pipeline

I have self-hosted agents on multiple environments that I am trying to run the same build/deploy processes on. I would like to be able to deploy the same code from a single repo to multiple systems concurrently. Thus, I have created an "overhead" pipeline, and several "processes" pipeline templates. Everything seems to be going very well, except for when I try to perform checkouts of the same repo twice in the same pipeline execution. I get the following error:
An error occurred while loading the YAML build pipeline. An item with the same key has already been added.
I would really like to be able to just click ONE button to trigger a main pipeline that calls all the templates requires and gives the parameters needed to get all my jobs done at once. I could of course define this "overhead" pipeline and then queue up as many instances as I need of it per systems that I need to deploy to, but I'm lazy, hence why I'm using pipelines!
As soon as I remove the checkout from Common.yml, the validation succeeds without any issues. If I keep the checkout in there but only call the Common.yml once for the entire Overhead pipeline, then it succeeds without any issues as well. But the problem is: I need to pull the contents of the repo to EACH of my agents that are running on completely separate environments that are in no way ever able to talk to each other (can't pull the information to one agent and have it do some sort of a "copy" to all the other agent locations.....).
Any assistance is very much welcomed, thank you!
The following is my "overhead" pipeline:
# azure-pipelines.yml
trigger:
none
parameters:
- name: vLAN
type: string
default: 851
values:
- 851
- 1105
stages:
- stage: vLAN851
condition: eq('${{ parameters.vLAN }}', '851')
pool:
name: xxxxx
demands:
- vLAN -equals 851
jobs:
- job: Common_851
steps:
- template: Procedures/Common.yml
- job: Export_851
dependsOn: Common_851
steps:
- template: Procedures/Export.yml
parameters:
Server: ABTS-01
- stage: vLAN1105
condition: eq('${{ parameters.vLAN }}', '1105')
pool:
name: xxxxx
demands:
- vLAN -equals 1105
jobs:
- job: Common_1105
steps:
- template: Procedures/Common.yml
- job: Export_1105
dependsOn: Common_1105
steps:
- template: Procedures/Export.yml
parameters:
Server: OTS-01
And here is the "Procedures/Common.yml":
steps:
- checkout: git://xxxxx/yyyyy#$(Build.SourceBranchName)
clean: true
enabled: true
timeoutInMinutes: 1
- task: UsePythonVersion#0
enabled: true
timeoutInMinutes: 1
displayName: Select correct version of Python
inputs:
versionSpec: '3.8'
addToPath: true
architecture: 'x64'
- task: CmdLine#2
enabled: true
timeoutInMinutes: 5
displayName: Ensure Python Requirements Installed
inputs:
script: |
python -m pip install GitPython
And here is the "Procedures/Export.yml":
parameters:
- name: Server
type: string
steps:
- task: PythonScript#0
enabled: true
timeoutInMinutes: 3
displayName: xxxxx
inputs:
arguments: --name "xxxxx" --mode True --Server ${{ parameters.Server }}
scriptSource: 'filePath'
scriptPath: 'xxxxx/main.py'
I managed to make checkout work with variable branch names by using template expression variables ${{ ... }} instead of macro syntax $(...) variables.
The difference is that, template expressions are processed at compile time while macros are processed at runtime.
So in my case I have something like:
- checkout: git://xxx/yyy#${{ variables.BRANCH_NAME }}
For more information about variables syntax :
Understand variable syntax
I couldn't get it to work with expressions but I was able to get it to work using repository resources following the documentation at: https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops
resources:
repositories:
- repository: MyGitHubRepo # The name used to reference this repository in the checkout step
type: git
name: MyAzureProjectName/MyGitRepo
ref: $(Build.SourceBranch)
trigger:
- main
pool:
vmImage: 'ubuntu-latest'
#some job
steps:
- checkout: MyGitHubRepo
#some other job
steps:
- checkout: MyGitHubRepo
- script: dir $(Build.SourcesDirectory)

How to stop GitHub Action build when SonarQube scan fails

I have a scan step built into my GitHub Action build and that is working fine. I reach out to my company's SonarQub instance and the scan is initiated. The problem I am having is trying to stop a build if there is a failure. For the life of me I can't seem to find a way to do that. Also, when I watch the scan it appears as though the next steps might be happening before it finishes (not positive on that but thought I would mention it). Any ideas??
name: Build, test, & deploy
on: [push]
jobs:
sonarqube:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
# Triggering SonarQube analysis as results of it are required by Quality Gate check
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action#master
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
- name: SonarQube Quality Gate check
uses: sonarsource/sonarqube-quality-gate-action#master
# Force to fail step after specific time
timeout-minutes: 5
env:
SONAR_TOKEN: ${{ secrets.ADAM_SONAR_TOKEN }}
build:
name: Project build & package
if: "!contains(github.even.head_commit.message, '[skip-ci]')"
runs-on: ubuntu-latest
env:
#environment var for this job
#### the rest of the build is below this area - I didn't think it was necessary to include
You should use needs in your build job:
build:
needs: sonarqube
name: Project build & package
You can find information here: https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow
The answer is using "needs": https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds

How to use Go Release Binary GitHub Action

Anyone able to get Go Release Binary GitHub Action working? which is supposed to
Automate publishing Go build artifacts for GitHub releases through GitHub Actions
The readme looks rather simple, but I've tried all my imaginations to get it working but not avail. Similar questions has been asked in its issue tracks but got no answer.
Somebody help please.
BTW, while searching for the answer, I came upon this commit logs, which is quite interesting/amusing to read. I.e., it seems to be quite a battle to get it working, but the author gave up eventually (no any releases from his/her latest commits/tags)
Conclusion:
Turns out that my project does not have go mod and there were issues in Go Release which stops it from working. It was then fixed by this and this.
I actually wrote my own release workflow for generating Go binaries.
The only non-obvious steps from my point of view are:
I have a release note generation step where I include a list of non-merge commits since the last release tag.
I use a matrix build for GOOS and GOARCH pairs and do some Bash string manipulation in the "Get OS and arch info" step.
The nice thing about softprops/action-gh-release is that you can keep adding artifacts to the same release as long as the workflow run is triggered by a push to the same tag.
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
name: Latest Release
defaults:
run:
shell: bash
jobs:
lint:
name: Lint files
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout#v2
- uses: actions/setup-go#v2
with:
go-version: '1.16.3'
- name: golangci-lint
uses: golangci/golangci-lint-action#v2.5.2
with:
version: latest
test:
name: Run tests
runs-on: 'ubuntu-latest'
needs: lint
steps:
- uses: actions/checkout#v2
- uses: actions/setup-go#v2
with:
go-version: '1.16.3'
- run: go test -v -cover
release:
name: Create Release
runs-on: 'ubuntu-latest'
needs: test
strategy:
matrix:
# List of GOOS and GOARCH pairs from `go tool dist list`
goosarch:
- 'aix/ppc64'
# etc
steps:
- name: Checkout code
uses: actions/checkout#v2
with:
fetch-depth: 0
- uses: actions/setup-go#v2
with:
go-version: '1.16.3'
- name: Get OS and arch info
run: |
GOOSARCH=${{matrix.goosarch}}
GOOS=${GOOSARCH%/*}
GOARCH=${GOOSARCH#*/}
BINARY_NAME=${{github.repository}}-$GOOS-$GOARCH
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
echo "GOOS=$GOOS" >> $GITHUB_ENV
echo "GOARCH=$GOARCH" >> $GITHUB_ENV
- name: Build
run: |
go build -o "$BINARY_NAME" -v
- name: Release Notes
run:
git log $(git describe HEAD~ --tags --abbrev=0)..HEAD --pretty='format:* %h %s%n * %an <%ae>' --no-merges >> ".github/RELEASE-TEMPLATE.md"
- name: Release with Notes
uses: softprops/action-gh-release#v1
with:
body_path: ".github/RELEASE-TEMPLATE.md"
draft: true
files: ${{env.BINARY_NAME}}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

How to run Xcode tests with yml?

It seems like it should be pretty simple, I just want to trigger a build and unit tests to be executed every time a developer pushes to their fork. GithubActions.
I’m creating a macOS app.
Here is what I'm trying. It doesn't work.
name: Smoke Test CI
on: [push, merge]
jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout#v1
- name: Execute full install
- name: Xcodebuild Action
uses: sersoft-gmbh/xcodebuild-action#v1.3

Categories

Resources