Copy files with github-action - bash

I am trying to write a GitHub action that makes a copy of a file in my repo into a different subdir in the repo. This is my dir structure (before the file is copied)
my_project
|_ .github
| |_ workflows
| |_ run_tests.yml
| |_ copy_file.yml
|_ tests
| |_ testthat
| |_ test1.R
| |_ test2.R
|_ my_file.json
|_ copyfile.sh
This is what I want my file structure to be after the file is copied
my_project
|_ .github
| |_ workflows
| |_ run_tests.yml
| |_ copy_file.yml
|_ tests
| |_ testthat
| | |_ test1.R
| | |_ test2.R
| |_ copy_of_my_file.json
|_ my_file.json
|_ copyfile.sh
So basically, my GitHub action should make a copy of my_file.json named copy_of_my_file.json and place it inside the tests sub dir. I've built a bash script with the following
#!/bin/bash
cp my_file.json tests/copy_of_my_file.json
Locally, I run chmod u+x copyfile.sh and then bash copyfile.sh and the file is indeed copied. My copy_file.yml workflow is as follows:
name: Copy my_file.json to tests subdirectory
on: [push, pull_request, workflow_dispatch]
jobs:
run:
runs-on: [ubuntu-latest]
steps:
- name: Checkout 🛎️
uses: actions/checkout#v2
- name: Make copy of my_file.json 📚
run: |
chmod u+x "${GITHUB_WORKSPACE}/copyfile.sh"
bash "${GITHUB_WORKSPACE}/copyfile.sh"
The action runs with no errors, but the file doesn't get copied. I tried other actions from the GitHub Marketplace with no luck. I also tried changing the action's run to simply cp my_file.json tests/copy_of_my_file.json but it doesn't work either.

The problem was that the file needed to be committed to the repo. One could write its own commit action or pick from the GitHub Actions Marketplace.
In the background, what happens is that the action is run on a GitHub server. The checkout action fetches the files from the repo. Anything that is done afterward happens in that server. Therefore, anything that needs to be "saved", must be pushed to the repo or generate an action artifact.

Related

'misexec /x <productCode>' copy some files in InstallSource folder to somewhere

I have a install program looks like
SomeRoot
|_ customSetup.exe
|_ \productA
| |_ productA.msi
| |_ setup.exe
| |_ ISSetup.dll
| |_ setup.ini
| |_ <other file generated by installshield..>
| ...
When user use customSetup.exe to install productA, customSetup.exe will call \productA\setup.exe.
Sometimes, when User have already installed productA, and customSetup.exe
have to uninstall productA first, but the installshield's uninstall string
not found, customSetup.exe will call 'msiexec /x' to uninstall productA.
Under the mentioned situation, I found files under \productA was copied to SomeRoot, I have no idea how it works.

Can't get local sphinx-apidoc templates to work

Re: Using sphinx-apidoc to automatically generate API reference from docstrings via the autodoc extension...
I copied the global /site-packages/sphinx/templates/apidoc/package.rst_t template to a local folder, and made a nonsense edit. When I built the API docs, the nonsense edit wasn't visible ie. the local templates didn't seem to override the global ones.
Here's my local docs/source directory:
|_ docs
|_ source
|_ templates
| package.rst_t
|_ conf.py
|_ index.rst
conf.py contains this directive:
templates_path = ['templates']
I built the API docs using this command:
sphinx-apidoc -e -M -f --templatedir=./templates -o ./source/autodoc ../myproject
Can anyone see what's going wrong?

How are NuGet repos organized?

I decided to push a .NET Standard class library to an existing local NuGet repo at my workplace.
I did it by having the NuGet package automatically pushed after the build in Visual Studio:
nuget push [PACKAGE_FILENAME] -Source [REPO_ON_THE_NETWORK]
Prior to my push, there were 3 pre-existing packages for other projects in the repo. After my push, the only project visible - via the NuGet Package Manager UI in Visual Studio - was the one I just pushed. I can consume my project from the NuGet repo without issues.
I took a look in the folder itself on the network, and this is what I saw:
[ ] Repo
|
|_ [ ] Proj1
| |
| |_ [ ] v1.0.0
| | |
| | |_ [ ] lib
| | | |
| | | |_ [ ] net20
| | | | |
| | | | |_ .dll
| | | | |_ .pdb
| | | |
| | | |_ [ ] net46
| | | |
| | | |_ .dll
| | | |_ .pdb
| | |
| | |_ .nupkg
| | |_ .nupkg.sha512
| | |_ .nuspec
| |
| |_ [ ] v1.0.1
| |
| |_ .nupkg
| |_ .nupkg.sha512
| |_ .nuspec
|
|_ [ ] MyRecentlyPushedProj
|
|_ .nupkg
I have three questions:
Why are the folder's organized in such different ways? Notice how one folder has a sub-folder with the actual project binaries, while the others don't. Also notice how my recently-pushed project lacks everything except for the NuGet package file.
When we manually delete the recently-pushed project from the repo, then the old projects reappear in the NuGet Package Manager UI. Does having differently-organized folders mess with NuGet's ability to scan the repo? Has the way NuGet organizes the projects changed over time (with newer versions)?
How am I able to consume the recently-pushed project successfully without the folder containing any of the binaries?
From the hierarchy tree you drew, I can see some differences:
Your package doesn't come with a version.
Your package doesn't have a lib folder.
Now, there are two ways of publishing a NuGet package with NuGet CLI: push and add.
The main difference is that add is for non-HTTP package source (as stated on MSDN) and that it publishes the package in a hierarchic manner, while push doesn't always (and it usually depends on how the feed was initialized).
My recommendation is that you check the documentation I added, and based on that decide whether to use one command or the other. From what I can gather, you should use add.
Hope this helps.

Step definition from multiple files for same scenario

I have a scenario where its step definitions resides in multiple files. For instance the login step resides in login_steps.rb and a search related step resides in search_steps.rb
Cucumber outputs undefined steps for any step that is not in login_steps.rb. The step definitions are run only when its present in login_steps.rb. Is it required to place all the step definitions of a scenario in the same file?
My folder structure
Project folder
└─ features
├─ pages
├─ scenarios
├─ step_definitions
└─ support
Command I used:
cucumber -r features features\scenarios\Test.feature
The whole point to Cucumber and the POM is that you have flexibility and do not need to re-write your steps per feature file. This is what my directory structure looks like:
Root
- features
- step_definitions
- step_definition.rb
- support
- env.rb
- lib
- BasePage.rb
- feature.feature
Basically, with this directory structure, it doesn't matter where your step definitions are AS LONG AS YOU REQUIRE THE SPECIFIC PAGE YOU'RE REFERENCING (your BasePage.rb file, for example)
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'pages', 'BasePage')
And /^I do something$/ do
#page = BasePage.new(#test_env)
#page.verify_el(css)
end
I'm not familiar with the specifics of RoR and cucumber, but I do use cucumber-jvm. Using steps from different files is supported. Note the documentation https://github.com/cucumber/cucumber/wiki/Cucumber-Backgrounder#where-do-i-put-tests specifically mentions it.
Sorry I can't be more help with the specific issue, but what you are trying to do (use step from different files) is workable.
This might be a "violation" but I would combine the answers from Whitney Imura and Dave W just to make the answer more clear...
You ask:
"Is it required to place all the step
definitions of a scenario in the same file?"
No. You can place your step definitions in logically distinct files within various folders, as you see fit (example below). After all, it is just ruby code.
Essentially Your command is correct for running an individual feature that has step definitions in various other folders...
cucumber -r features features\entities\entity.feature
If you do not run it as above, you will get missing stepdefs... Here I execute tests on a current project as a means to demonstrate:
cucumber
60 scenarios (14 undefined, 46 passed)
409 steps (32 skipped, 26 undefined, 351 passed)
cucumber -r features
60 scenarios (60 passed)
409 steps (409 passed)
As described in the Cucumber documentation, you can arrange your tests to suite your logical breakdown of your features:
|__ features
| |__ entities
| | |__ entity.feature
| | |__ step_definitions
| | |__ anything.rb
| | |__ entity_steps.rb
| |__ locations
| | |__ location.feature
| | |__ step_definitions
| | |__location_steps.rb
| |__ sites
| | |__ step_definitions
| |__ step_definitions
| | |__ local_assert_steps.rb
| | |__ local_crud_response_steps.rb
| | |__ local_email_steps.rb
| | |__ local_file_steps.rb
| | |__ local_script_steps.rb
| | |__ local_steps.rb
| | |__ local_web_steps.rb
` | |__ local_xml_file_steps.rb
|__ support
|__ env.rb
|__ local_env.rb
|__ local_transforms.rb

Octopress - dealing with sub-directory folder structure for pages

Is it possible to have a subdirectory for all my pages?
Currently:
rake new_page['siht-daer-uoy-nac']
generates the markdown files like so:
source/
|_ _posts
|_ <some-other-directories>
|_ siht-daer-uoy-nac
|_ index.markdown
then doing a
rake generate
takes care of everything and spurts out a pretty html file.
My problem/question:
Call me OCD afflicted, but i would like to have a directory structure like so:
source/
|_ _posts
|_ <some-other-directories>
|_ _pages
|_ siht-daer-uoy-nac
|_ index.markdown
Having my top directory structure littered with a bunch of page slugs, makes me cry a little inside. I understand jekyll is merely a static page generator and plays its part only upto the point of html generation (and deployment).
Is it possible to maintain this kind of a folder structure for my pages?
Update:
I don't think it's possible out of the box to have a _pages directory without significantly messing around with octopress/jekyll source code (one of these days). In the meantime, a workaround to have a bunch of similar page like posts grouped is as ngm suggested below:
rake new_page["osx-essential-software/2011.markdown"]
# creates /source/osx-essential-software/2011/index.markdown
rake new_page["osx-essential-software/2010.markdown"]
# creates /source/osx-essential-software/2010/index.markdown
Not sure if it's by design or by accident, but if you do:
rake new_page["foo/nac-i-sey"]
you'll get a page for nac-i-sey under a foo subdirectory.
So if you wanted another page under foo, you could do:
rake new_page["foo/another-page"]

Resources