constellation
constellation copied to clipboard
GitHub Actions Improvements
Prerequisites
- [x] Put an X between the brackets on this line if you have done all of the following:
- Running the latest version of Constellation
- Attached the Support Package via
Help
>Support Package
- Checked the FAQs: https://github.com/constellation-app/constellation/wiki/FAQ
- Checked that your issue isn't already filed: https://github.com/constellation-app/constellation/issues
- Checked that there is not already a module that provides the described functionality: https://github.com/constellation-app/constellation/wiki/Catalogue-of-Repositories
Description
Following the conversion from TravisCI to GitHub Actions #993 , there are a few improvements that could be made to round this ticket out. ~~1.Cache the downloaded dependencies within the Docker container. (tried using the cache action and mounting it to the correct folder on Docker but it seems to always cache nothing even though there is only one .ivy2/cache directory at /root/)~~ (Fixed with #1021 ) 2.Add an action to package up the release on tagged versions.
Steps to Reproduce
~~1. Trigger a github action to run, and view the logging in the checks tab to ensure that the cache is reloaded between triggers of docker containers. The cache is stored with a hash of the ivy.xml file.~~
Expected behaviour: ~~the cached dependencies will be reloaded into the correct docker .xml file and will not dowload any further dependencies if working correctly.~~
Actual behaviour: ~~The dependency is compared, found to be correct - and then loaded into docker. The cache is empty at that point. Where it should be full of downloads.~~
Reproduces how often: 100%
Additional Information
~~The cache action is specified in .github -> workflows -> build-and-scan.yml
~~
~~The cache directory is set at ${HOME}/.ivy2/cache~~
~~This is then mounted when launching the docker container.~~
~~Saving the cache seems to work at correct time, but quite possibly doesn't save the information into the cache for some reason or another.~~
To also add - Sonar scanning does not seem to be picking up test coverage. I believe this is because it is running one docker container for the tests, and another for scanning with sonar. Ideally we need the resultant files that are output by jacoco to be within the container of the sonar scan. They currently run simultaneously - so unless there is some tricky wait call in github actions that would allow us to add the file beforehand - I don't have any great ideas on how to resolve this.
The remaining work on this ticket is to configure a GitHub action to build constellation when a tagged version is made. I'll tag this ticket as help wanted as I personally have not much experience in the process of building constellation.
No worries @aldebaran30701. I think the other thing also is to make sure the ivy downloaded cache is retained to prevent it downloading it each time. Both of us are building experience in this space and I am keen to take a look but happy to keep the help wanted for now.
To configure a build on a tag, the best "I think" way to implement it is in a GitHub Action. This allows for events to be triggered on push, or at a specific tag and then running scripts on the GitHub Actions server.
On a specific tag, the Action will run a docker image which will handle the build process. You will able to then use the Action upload artifact to upload the build to this repository as an artifact from the Action. ^ There may also be a way to just straight away release it into the github releases section. That'll take a google to find out.
Here is how I've implemented the current pipeline, GitHub looks in this folder for .yml files to use as actions. A new one will need to be made to handle the build. https://github.com/constellation-app/constellation/blob/master/.github/workflows/build-and-scan.yml
https://faun.pub/automate-your-build-release-with-github-actions-367c0febf5fd Halfway down this page you can see they upload the artifact. This will allow someone to download it from the action uploads section. Here is an example of an artifact from an action: https://github.com/aldebaran30701/constellation-app.github.io/actions/runs/1164837630
Thanks @aldebaran30701 I agree this would be a good way forward and also for documenting your findings.
Gulp.
@aldebaran30701 @CrucisGamma I am tempted to look at this again but won't get to it until tomorrow or Friday. If you beat me to it then let me know.
Have started looking at this more seriously now :) I can see the existing .yml files in https://github.com/constellation-app/constellation/tree/master/.github/workflows and doing research on github actions so I can get my head around them
I think I will have to unassign myself from this task - it's taking longer than expected and will be pulled away for most of next week :( I did work out some things - you can have githubactions run in your fork. These were the type of yml files (in a conglomerated mass) I'd gotten from the internet.
# Create build job in workflow
name: Build Next.js web application
on: push
jobs:
build-project:
name: Build Project
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install NPM dependencies
run: npm install
- name: Build project assets
run: npm run build
on: push
jobs:
build-project:
name: Build Project
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install NPM dependencies
run: npm install
- name: Build project assets
run: npm run build
- name: Upload static site
uses: actions/upload-artifact@v2
with:
name: static-site
path: .next/
uses: actions/upload-artifact@v2
with:
name: static-site
path: .next/
release-project:
name: Release Project
runs-on: ubuntu-latest
needs: build-project
name: Release Project
runs-on: ubuntu-latest
needs: build-project
# Download artifact
- name: Download site content
uses: actions/download-artifact@v2
with:
name: site-build
uses: actions/download-artifact@v2
with:
name: site-build
# View contents of downloaded artifact
- name: View content
run: ls -R
# Create GitHub release
- name: Create GitHub release
id: create-new-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.run_number }}
release_name: Release ${{ github.run_number }}
id: create-new-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.run_number }}
release_name: Release ${{ github.run_number }}
# Compress folder
- name: Archive site content
uses: thedoctor0/zip-release@master
with:
filename: site.zip
uses: thedoctor0/zip-release@master
with:
filename: site.zip
# Upload asset to release
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-new-release.outputs.upload_url }}
asset_path: ./site.zip
asset_name: site-v${{ github.run_number }}.zip
asset_content_type: application/zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-new-release.outputs.upload_url }}
asset_path: ./site.zip
asset_name: site-v${{ github.run_number }}.zip
asset_content_type: application/zip
no worries @CrucisGamma thanks for your help
This issue is stale because it has been open for 6 months with no activity. Consider reviewing and taking an action on this issue.
This issue is stale because it has been open for 6 months with no activity. Consider reviewing and taking an action on this issue.