https://github.com/KillerJoke623/Practic
I've got a problem with my University practic, can you help me please
name: Jupyter
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v3
- name: Setup Python
uses: actions/setup-python#v4.0.0
with:
cache: pip
python-version: '3.7'
- name: Install Dependencies
run: pip install -r requirements.txt
- name: Exeute Notebook
run: jupyter-nbconvert --to html practic.ipynb
- name: Upload a Build Artifact
uses: actions/upload-artifact#v3.1.0
with:
name: Artifact
path: practic.html
Related
I am working on configuring a deployment pipeline for my team. We are using Github Actions and I have most of it sorted, but ran into an issue when trying to run certain steps in a sequential order.
The app is ASP.NET Core MVC with some Blazor support. We are using webpack, webpack-cli css-loader & style-loader to bundle and minify our CSS and JS files.
The issue: I need to be able to run the npm build task before the .net core publish task in github actions. I am able to get the steps to run sequentially HOWEVER, the files generated in step 1 (the npm build) don't seem to be available to the .net core publish actions which happens after.
Question: what do I need to do in order to have the newly generated npm build files be used by the .net core publish action? I assume its a matter of moving them around to the correct location, however I am having trouble finding any good info on this. I have done Much trial and error, and research has been unfruitful.
Below is the yaml file and webpack file being used, and the command run is just npm run build
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .net Publish
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
job1:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [15.x]
steps:
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node#v3
with:
node-version: ${{ matrix.node-version }}
- name: build webpack
uses: actions/checkout#v1
- run: ls -a
- run: npm i
working-directory: ./ClientApp
- run: npm run build
working-directory: ./ClientApp
- run: pwd
- run: ls -a
- name: Persist npm build output
uses: actions/upload-artifact#v3
with:
name: npm-post-build
path: |
./wwwroot/dist/**
job2:
needs: job1
runs-on: ubuntu-latest
steps:
- name: Install Octopus Deploy CLI
uses: OctopusDeploy/install-octopus-cli-action#v1
with:
version: '*'
- uses: actions/checkout#v3
- name: Setup .NET
uses: actions/setup-dotnet#v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: replace dist with npm build artifact
uses: actions/download-artifact#v3
with:
name: npm-post-build
path: npm-post-build
- shell: bash
run: |
ls -a
rm -r wwwroot/dist
ls wwwroot
mv npm-post-build wwwroot/dist
ls wwwroot/dist
- name: Build
run: dotnet build --no-restore
- name: Publish
run: dotnet publish -p:PublishProfile=FolderProfile -o website
- name: package
run: |
shopt -s globstar
paths=()
for i in website/**; do
dir=${i%/*}
echo ${dir}
paths=(${paths[#]} ${dir})
done
eval uniquepaths=($(printf "%s\n" "${paths[#]}" | sort -u))
for i in "${uniquepaths[#]}"; do
echo $i
done
packages=()
versions=()
for path in "${uniquepaths[#]}"; do
dir=${path}/../../../..
parentdir=$(builtin cd $dir; pwd)
projectname=${parentdir##*/}
octo pack \
--basePath ${path} \
--id ${projectname} \
--version 1.0.0 \
--format zip \
--overwrite
packages=(${packages[#]} "${projectname}.1.0.0.zip")
versions=(${versions[#]} "${projectname}:1.0.0")
done
printf -v joined "%s," "${packages[#]}"
echo "::set-output name=artifacts::${joined%,}"
printf -v versionsjoinednewline "%s\n" "${versions[#]}"
versionsjoinednewline="${versionsjoinednewline//'%'/'%25'}"
versionsjoinednewline="${versionsjoinednewline//$'\n'/'%0A'}"
versionsjoinednewline="${versionsjoinednewline//$'\r'/'%0D'}"
echo "::set-output name=versions_new_line::${versionsjoinednewline%\n}"
echo "prepackage complete ${packages}"
- name: Push a package to Octopus Deploy
uses: OctopusDeploy/push-package-action#v3
env:
OCTOPUS_URL: https://****.octopus.app/
OCTOPUS_API_KEY: *****
OCTOPUS_SPACE: 'Default'
with:
overwrite_mode: OverwriteExisting
packages: runner.1.0.0.zip
const path = require('path');
module.exports = {
entry: {
site: '../wwwroot/js/site.js'
},
output: {
filename: '[name].entry.js',
path: path.resolve(__dirname, '..', 'wwwroot', 'dist')
},
devtool: 'source-map',
mode: 'development',
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(eot|woff(2)?|ttf|otf|svg)$/i,
type: 'asset'
},
]
}
};
npm CI && npm run build is failing in github actions I'll paste the yaml file below.
name: Deploy to Firebase Hosting on PR
"on": pull_request
jobs:
build_and_preview:
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy#v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.SECRET }}"
projectId: projectId
enter image description here
I tried to remove npm CI, deleted node_modules package and package.json file in local and re-installed everything.
It looks like you don't have package-lock.json in the root directory.
You can add it using: npm i --package-lock-only
And try to set the ci to empty, eg:
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout#v3
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build
env:
CI: ""
I setup for my R package repository a pkgdown workflow.
The .github/workflows/pkgdown.yaml file:
on:
push:
branches: [main, master]
release:
types: [published]
workflow_dispatch:
name: pkgdown
jobs:
pkgdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-pandoc#v1
- uses: r-lib/actions/setup-r#v1
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies#v1
with:
extra-packages: pkgdown
needs: website
- name: Deploy package
if: contains(env.isPush, 'true')
run: |
git config --local user.email "actions#github.com"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
The pkgdown workflow works fine, but it fails to update the GitHub pages.
I setup the gh-pages branch as explained in the GitHub documentation, so the workflow pages-build-deployment is present, but when I push on main branch it doesn't run.
I realized the problem was in the if: contains(env.isPush, 'true') line. The condition is never true nor false, since there is no attribute isPush under env, hence the lines
run: |
git config --local user.email "actions#github.com"
git config --local user.name "GitHub Actions"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
were never executed.
To solve the problem, either modify the env part:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
isPush: ${{ github.event_name == 'push' }}
or remove the if condition before the run command.
I want to adapt the boilerplate code in the r-lib/actions repo to add a linting check to my (fake) package. I have my workflow yaml as follows:
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
name: lint
jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./mystarwars
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-r#v1
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), "../.github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), "../.github/R-version")
shell: Rscript {0}
- name: Restore R package cache
uses: actions/cache#v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('../.github/R-version') }}-1-${{ hashFiles('../.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('../.github/R-version') }}-1-
- name: Install dependencies
run: |
install.packages(c("remotes"))
remotes::install_deps(dependencies = TRUE)
install.packages(c("lintr"))
shell: Rscript {0}
- name: Install package
run: R CMD INSTALL .
- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
However, I get errors when trying to install lintr in the "Install dependencies". This step fails (silently), so then when it reaches the "Lint" step it fails with Error: Error in loadNamespace(x) : there is no package called ‘lintr’.
This remains the case whether I use install.packages(c("lintr")) or remotes::install_cran("lintr").
HERE is the full log of the "Install dependencies" step on GitHub Actions.
I am using GitHub actions for CI of my R package. I am trying using both testthat and shinytest in my package. I have the package structure set up correctly according to the shinytest documentation. When I run R-CMD-CHECK in RStudio, my package (including both testthat and shinytest testing works).
My GitHub Actions .yaml workflow is:
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
name: R-CMD-check
jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
strategy:
fail-fast: false
matrix:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
steps:
- uses: actions/checkout#v2
- uses: r-lib/actions/setup-r#v1
with:
r-version: ${{ matrix.config.r }}
- uses: r-lib/actions/setup-pandoc#v1
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache#v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
while read -r cmd
do
eval sudo $cmd
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "20.04"))')
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}
- name: Upload check results
if: failure()
uses: actions/upload-artifact#main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
When I commit to the repository, the check fails on Windows and Mac OS but works on Ubuntu.
The error that I am I am getting on both Windows and Mac OS is:
> test_check("mypackage")
-- 1. Error: application works (#test-appdir.R#6) -----------------------------
PhantomJS not found.
I don't think this is a problem with my package or tests. I think there is something misconfigured about my .yaml. How can I resolve this issue with PhantomJS in my workflow?
The easy solution will be to go to the project where there is used PhantomJS and the Github Actions is turned on. We will go to shiny project and precisely to:
https://github.com/rstudio/shiny/blob/master/.github/workflows/R-CMD-check.yaml
We could find out there that:
- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}
- name: Find PhantomJS path
id: phantomjs
run: |
echo "::set-output name=path::$(Rscript -e 'cat(shinytest:::phantom_paths()[[1]])')"
- name: Cache PhantomJS
uses: actions/cache#v1
with:
path: ${{ steps.phantomjs.outputs.path }}
key: ${{ runner.os }}-phantomjs
restore-keys: ${{ runner.os }}-phantomjs
- name: Install PhantomJS
run: >
Rscript
-e "if (!shinytest::dependenciesInstalled()) shinytest::installDependencies()"
We easily could check that there is separate chunk of code only to be sure that PhantomJS localization is known or if it should be installed.
You could paste this part of code to your yaml file. However the best way might to be follow the pipeline of shiny project,
It's hard to investigate the issue without detailed logs and no information about what dependencies (remotes) are being installed in Query dependencies step. It seems the PhantomJS dependency is not being installed at all. The workflow succeeds on ubuntu-20.04 because the runner has PhantomJS installed out-of-the-box. You can see all the installed software on provided runner types here. The other runner types used in the workflow above (windows-latest and macOS-latest) are missing PhantomJS. That's why your workflow fails on Windows and MacOS but succeeds on Ubuntu.