I have a demo repo https://github.com/sh977218/Angular-with-Playwright to try to run playwright with Angular on GitHub's action and publish the result to GitHub Page. I'm able to achieve that, but I'd like to improve it by publish each Pull Request's playwright result to GitHub Page and they are all available at same time.
Can someone guide me on how to do this?
This is the github action yml file
name: Playwright Tests
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
jobs:
Playwright-tests:
timeout-minutes: 60
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
actions: write
checks: write
contents: write
deployments: write
id-token: write
issues: write
discussions: write
packages: write
pages: write
pull-requests: write
repository-projects: write
security-events: write
statuses: write
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout#v3
- uses: actions/setup-node#v3
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact#v3
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
- name: Setup Pages
uses: actions/configure-pages#v2
- name: Upload artifact
uses: actions/upload-pages-artifact#v1.0.7
with:
path: playwright-report/
- name: Deploy Playwright result to Github Pages
id: deployment
uses: actions/deploy-pages#v1.2.4
Thanks!
Related
I have created a github action workflow to deploy code but now i need to add the approval functionality before deploying, once build is done approver should get a mail notification to approve the deployment, how can i achieve this?
below is my workflow file :
name: DEV Workflow
on:
push:
branches: [ dev ]
pull_request:
branches: [ dev ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: '1.8'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn clean install
- name: Unit Testing
run: echo "Hello World!"
- name: Deploy
run: echo "Hi World!"
Deploy-dev:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: '1.8'
distribution: 'adopt'
cache: maven
- name: Build with Maven
run: mvn clean install
- name: Deploy
run: echo "Hi World!"
unit-testing:
needs: Deploy-dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: '1.8'
distribution: 'adopt'
cache: maven
- name: Unit Testing
run: echo "Hello World!"
On Github Actions you can use Environments to set required approvers (this will send emails to the users when needed).
You can list multiple teams / people that can approve the job, and only 1 person needs to approve it from that list for the workflow to continue, as explained to this other section of the documentation:
Use required reviewers to require a specific person or team to approve workflow jobs that reference the environment. You can list up to six users or teams as reviewers. The reviewers must have at least read access to the repository. Only one of the required reviewers needs to approve the job for it to proceed.
If you don't want to use this solution, a workaround could be to use this manual-approval action, which also allows you to inform more than 1 approver.
I would like to run automated Playwright tests with Github Actions. I created a cronjob for this, but it has no effect. What else should I consider? Here is the content of my .github/workflows/playwright.yml:
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
schedule:
- cron: '12 14 * * Mon-Fri'
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-node#v2
with:
node-version: '14.x'
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact#v2
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
In the future, if you have to create cron jobs, I can recommend crontab.guru. Its UI is simple to create effective cron schedules.
The run came 2 hours late. Patience is required here.
I have a github action pipeline with multiple jobs, and each job has its own checkout step. But I am not sure if this can have some side effects.
What happens when there is another commit when my pipeline is already running? Will my pipeline run then checkout the changes from the other commit?
How can I avoid this? Should I use "actions/cache" instead of checkout the code in every step? Or is "actions/upload-artifact" and "actions/download-artifacts" better? Or maybe a totally different solution?
Example of my pipeline
name: my_job
on: [push]
jobs:
build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-java#3
with:
distribution: 'adopt'
java-version: '17'
cache: 'maven'
- name: test
run: ./mvnw clean verify
- name: build
run: ./mvnw package
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- name: infrastructure
run: ./script/infrastructure.sh
- name: deploy app
run: ./script/delploy_app.sh
I am new to writing GH Actions. I am working on a task to remove common workflows and use the reusable workflow feature available. I am now able to get my workflows to run sequentially which is great. However, the 2nd workflow is resulting in an unexpected error message seemingly related to the yarn dependency workflow not saving to the cache as I would have expected it:
Run yarn lint
... snip
myPackage: /bin/sh: 1: concurrently: not found
Could you take a look at see if this looks ok? For now, my goal is to have a workflow for pull-request which calls yarn and lint as the resuable features:
name: pull-request
on:
pull_request:
branches:
- main
jobs:
yarn:
uses: ./.github/workflows/yarn.yml
validate_lint:
needs: yarn
uses: ./.github/workflows/validate_lint.yml
with:
name: Yarn
on:
workflow_call:
jobs:
yarn_and_deps:
name: Run Lint
runs-on: ubuntu-latest
steps:
- name: Checkout Git repository
uses: actions/checkout#v3
- name: Enable node
uses: actions/setup-node#v3
with:
node-version: 16
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache#v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
run: yarn install --frozen-lockfile && yarn bootstrap
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
and
name: Validate Lint
on:
workflow_call:
jobs:
run_lint:
name: Run Lint
runs-on: ubuntu-latest
- name: Enable node
uses: actions/setup-node#v3
with:
node-version: 16
cache: 'yarn' # <<--- THIS CACHE IS NOT FOUND 🤷🏻♂️
# NOTE: if I add in all the "yarn cache/install" commands from above workflow, this passes.
steps:
- name: Validate Lint
run: yarn lint
The error happens here in the Validate Lint job because it appears that the cache is not found. I made the yarn job to avoid re-creating the wheel for each job.
What is wrong with my expectations on the cache v how it actually works? Having to Install dependencies step each job feels like overkill.
Turns out each workflow is its own docker container. Therefore, if I run yarn in workflow 1's container, workflow 2 has no knowledge/access to the cache.
The closest thing appears to be an upload/download "sharing of data", but this has it's own drawbacks - such as downloading a node_modules folder can be slower than just installing the dependencies.
Unfortunately, the solution seems to be that there is repetition of code when each workflow has a dependency to the output of prior item.
I am getting the following error message on github actions when msbuild is run for my xamarin.android project:
_ResolveAndroidTooling:
Found Java SDK version 14.0.2.
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Legacy.targets(248,5): error XA0030: Building with JDK version `14.0.2` is not supported. Please install JDK version `11.0`
my actions.yaml looks like this:
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Android:
runs-on: macos-latest
steps:
- uses: actions/checkout#v2
- uses: actions/setup-java#v2
with:
distribution: 'adopt' # See 'Supported distributions' for available options
java-version: '11'
#- run: java -cp java HelloWorldApp
- uses: taori/xamarinandroid-signedbuild-action#v10
with:
csproj_path: src/Droid.csproj
signing_keystore: ${{ secrets.ANDROID_KEYSTORE }}
keystore_password: ${{ secrets.ANDROID_KEYSTORE_PASS }}
signing_key_alias: ${{ secrets.ANDROID_KEY_ALIAS }}
signing_key_password: ${{ secrets.ANDROID_KEY_PASS }}
configuration: "Release"
mono_version: "stable"
xamarin_android_version: "stable"
- uses: actions/upload-artifact#v2
with:
name: ipa
path: src/*.Droid/bin/Android/Release/**Signed.apk
Does actions/setup-java#v2 not install 11.x? Or is this an issue with msbuild not picking up on the environment variables set by that action?
References
Known issue for azure pipelines
Does actions/setup-java#v2 not install 11.x?
It should, since PR 132 and v2.
Try and simplify your action, to only keep the java installation part, and validate it does work:
- name: setup-java
uses: actions/setup-java#v2-preview
with:
distribution: 'adopt'
java-version: '11'
Then add back the other elements of your original action, and see when the issue manifests itself again.