my problem is that I can't run eunit tests for a single app or module without including the root app. My directory laylout looks a bit like this:
├── apps
│ ├── app1
│ └── app2
├── deps
│ ├── amqp_client
│ ├── meck
│ ├── rabbit_common
│ └── ranch
├── rebar.config
├── rel
└── src
├── rootapp.app.src
├── rootapp.erl
├── rootapp.erl
└── rootapp.erl
Now, what I can do is:
$ rebar eunit skip_deps=true
which runs the tests for all apps. Also, I can do:
$ cd apps/app1/
$ rebar eunit skip_deps=true
which runs the tests for app1 (I have a rebar.config in apps/app1 as well.
However, if I try
$ rebar eunit skip_deps=true apps=app1
does...nothing. no output. Trying verbose mode gives me:
$ rebar -vv eunit skip_deps=true apps=app1
DEBUG: Consult config file "/Users/myuser/Development/erlang/rootapp/rebar.config"
DEBUG: Rebar location: "/usr/local/bin/rebar"
DEBUG: Consult config file "/Users/myuser/Development/erlang/erlactive/src/rootapp.app.src"
DEBUG: Skipping app: rootapp
When I include the root app, it works:
$ rebar eunit skip_deps=true apps=rootapp,app1
Despite the fact, that I actually want to test app1, not rootapp, this is really uncomfortable since the SublimeErl plugin for SublimeText 2 will always set the apps to the app that the module under test is contained in. So the tests will always fail because actually no tests will run at all.
Long story short: Is there something I can configure in any of the rebar.config files to make it possible to run the tests for one app in /apps without including the root app?
Personally I prefer to put the main app into its own OTP compliant folder in apps. Just create a new app rootapp in apps and include it in your rebar.config:
{sub_dirs, ["apps/app1",
"apps/app2",
"apps/rootapp"]}.
You might also have to include the apps directory into your lib path:
{lib_dirs, ["apps"]}.
You might want to have a look into Fred Herbert's blog post “As bad as anything else”.
With this set up you should be able to run:
rebar skip_deps=true eunit
which will run all eunit tests of the apps in apps.
Related
I wrote a custom RDS module for my development team to consume for deploying RDS instances. I am using BitBucket for source control and I am trying to integrate a BitBucket pipeline to run terraform validate on my .tf files to validate syntax before making it consumable to the devs.terraform init runs fine but when I run terraform validate I get the following error: Error: Missing required argument. The argument "region" is required, but was not set. After looking at the documentation, I am confused why this command would check for a declared provider if it is not actually deploying anything? I am admittedly new to writing modules. Perhaps this isn't the right command for what I want to accomplish?
Terraform version: v0.12.7
AWS Provider version: 2.24
bitbucket-pipelines.yml:
image: hashicorp/terraform:full
pipelines:
branches:
master:
- step:
script:
- terraform version
- terraform init
- terraform validate
Module tree:
├── CHANGELOG.md
├── README.md
├── bitbucket-pipelines.yml
├── main.tf
├── modules
│ ├── db_instance
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ ├── db_option_group
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ ├── db_parameter_group
│ │ ├── README.md
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ └── variables.tf
│ └── db_subnet_group
│ ├── README.md
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── outputs.tf
└── variables.tf
The situation you've hit here is the bug described in Terraform issue #21408, where validation is checking that the provider configuration is complete even though you're intending to write a module that will inherit a provider.
There are two main workarounds for this at the time of writing. The easiest one-shot workaround is to set the environment variable AWS_DEFAULT_REGION to any valid AWS region then it should be used as a value for region and allow validation to pass.
To make that reproducible, you can use a test configuration which can serve a test bed for the module when you are developing it alone, outside the context of a particular caller. To do this, make a directory tests/simple (or really anything you like; the name doesn't matter) and put in it a test.tf file containing something like this:
provider "aws" {
region = "us-east-1"
}
module "under_test" {
source = "../.."
# Any arguments the module requires
}
You can then switch into that test directory and use the normal Terraform workflow to validate the whole configuration together:
cd tests/simple
terraform init
terraform validate
A nice benefit of this general idea of test configurations is that you can potentially also use them for end-to-end testing by running terraform plan or terraform apply with a suitable set of environment variables set, and you can have multiple test configurations to test different permutations of options and make sure they all pass validation and, if you do end-to-end testing, that they all work.
Even once that Terraform issue is fixed, test configurations will remain a nice technique for ensuring that your module works as a child module, separately from whether it's valid in isolation.
I have run into the same problem even though I have provided region to my provider configuration.
After some digging I have come across this thread from terraform's discussion board. The problem it seems is that for some undocumented reason, terraform expects AWS_DEFAULT_REGION environment variable to be set to a region value (eg. "us-west-1"). Setting it to a valid region has solved this problem for me.
You can find more information about setting environment variables for Terraform here.
Hope it helps your problem.
One or more of your TF resources has no region configured. To handle this without the AWS_DEFAULT_REGION env variable or if you have multiple regions, you can use provider aliases in your resources to specify your region. For example:
provider "aws" {
region = "us-east-1"
alias = "us"
}
...
resource "aws_cloudwatch_log_metric_filter" "hk_DBrecoverymode-UAT" {
provider = aws.us
...
}
So I've documented my whole API with swagger editor, and now I have my .yaml file. I'm really confused how I take that and generate the whole nodejs stuff now so that all those functions are already defined and then I just fill them in with the appropriate code.
Swagger Codegen generates server stubs and client SDKs for a variety of languages and frameworks, including Node.js.
To generate a Node.js server stub, run codegen with the -l nodejs-server argument.
Windows example:
java -jar swagger-codegen-cli-2-2-2.jar generate -i petstore.yaml -l nodejs-server -o .\PetstoreServer
You get:
.
├── api
| └── swagger.yaml
├── controllers
| ├── Pet.js
| ├── PetService.js
| ├── Store.js
| ├── StoreService.js
| ├── User.js
| └── UserService.js
├── index.js
├── package.json
├── README.md
└── .swagger-codegen-ignore
Problem
I write down lectures at university in LaTeX (which is really convenient for this purpose), and i want tex files to automatically compile in pdf.
I have couple of .tex files in my repository like this:
.
├── .gitlab-ci.yml
└── lectures
├── math
| ├── differentiation
| | ├── lecture_math_diff.tex
| | ├── chapter_1.tex
| | └── chapter_2.tex
| └── integration
| ├── lecture_math_int.tex
| ├── chapter_1.tex
| └── chapter_2.tex
└── physics
└── mechanics
├── lecture_physics_mech.tex
├── chapter_1.tex
└── chapter_2.tex
So main file, for example, lecture_math_diff.tex using
\include{chapter_1}
\include{chapter_2}
tags, to form whole lecture.
And as result, i want to have my build artifacts in pdf like this:
├── math
| ├── lecture_math_diff.pdf
| └── lecture_math_int.pdf
└── physics
└── lecture_physics_mech.pdf
What can be done here? Do i have to write any sh script to collect all tex files or use gitlab runners?
One approach would be to use a short script (e.g python or bash) and to run latexmk to generate the PDF files.
latexmk is a perl script, which compiles latex files automatically. A short introduction can be found here
With python3 the script could look like the following one:
# filename: make_lectures.py
import os
from subprocess import call
# configuration:
keyword_for_main_tex = "lecture"
if __name__ == "__main__":
tex_root_directory = os.getcwd()
for root, _, files in os.walk("."):
for file_name in files:
# check, if file name ends with `tex` and starts with the keyword
if file_name[-3:] == "tex" and file_name[0:len(keyword_for_main_tex)] == keyword_for_main_tex:
os.chdir(root) # go in the direcotry
os.system("latexmk -lualatex "+ file_name) # run latexmk on the mainfile
os.chdir(tex_root_directory) # go back to root directory in case of relative pathes
This script assumes, that only files to be compiled to PDF start with the keyword lecture (as in the question). But the if statement, which checks for files to build, could also be extended to more elaborate comparison as matching regular expressions.
latexmk is called with the command line flag -lualatex here to demonstrate how to configure the build process gloally. A local configuration possibility (for each single project) is given with .latexmkrc files, which are read and processed by latexmk.
If we call latexmk as shell command, we have to make sure, that it is installed on our gitlab runner (and also texlive). If Dockercontainer runners are registered (see here how it is done), then you just need to specify the name of an image from DockerHub, which leads to the example gitlab-ci.yml file below:
compile_latex_to_pdf:
image: philipptempel/docker-ubuntu-tug-texlive:latest
script: python3 make_lectures.py
artifacts:
paths:
- ./*.pdf
expire_in: 1 week
Fell free, to change the image to any other image you like (e.g. blang/latex:latest). Note, that the artifacts extraction assumes, that no other PDF files are in the repository.
A final remark: I did not try it, but it should also be possible to install texlive and latexmk directly on the gitlab runner (if you have access to it).
You can have a look at https://github.com/reallyinsane/mathan-latex-maven-plugin. With the maven or gradle plugin you can also use "dependencies" for your projects.
I have a Rails app and using Apache2 + Passenger + Capistrano on production server:
.
├── current -> releases/20150527234152
| ├── app
| ├── db
| ├── lib
| ├── ...
| └── public
| ├── assets
| └── uploads
| ├── 01.jpg
| ├── 02.jpg
| ├── 03.jpg
| └── ...
├── releases
| ├── 20150527212555
| ├── 20150527230415
| └── 20150527234152
├── repo
└── shared
I am not tracking the public/uploads directory (Where images are being uploaded by users). So whenever I do cap production deploy, the current links to the new version which won't have the uploads directory anymore. I am using carrierwave gem for image upload.
The only solution I can think of is to have capistrano run a script after deploying that moves the directory from older to latest revision.
Or
Have the uploads directory outside of the app. (If so, what's the best/safest location for it?)
I want to know which solution is better, or if there is a better option.
Cheers
The method you are looking for is called linked_dirs.
It accepts an Array of directories and will create a symlink to the directories specified across each successive deployment works well for directories that should persist even when other code is updated as is your case for uploads.
When you deploy what it does is it runs deploy:check:linked_dirs to confirm that the path exists and/or creates it. Then it runs deploy:symlink:linked_dirs which creates a symlink to this directory.
You can find it in the Official Documentation. The Rake Tasks can be Found Here
When developing OpenLaszlo applications, it's sometimes useful to generate the ActionScript 3 source code of an application written in lzx, e.g. when you want to compile OpenLaszlo into an Adobe AIR application.
What is the simplest way to generate the ActionScript 3 source code into a predefined folder?
The lzc command line tool which can be found in the $LPS_HOME/WEB-INF/lps/server/bin/ has on option for that:
--lzxonly
for as3 runtime, emit intermediate as files,
but don't call backend as3 compiler
By default the OpenLaszlo compiler will generate the ActionScript 3 code into the system specific Java temp folder, but the $JAVA_OPTS environment variable can be used to change that folder.
Here's an example of how the command can be used in combination with $JAVA_OPTS on Linux:
a) Create a simple LZX file, e.g.
<canvas>
<button text="Hello world" />
</canvas>
and save it as test.lzx.
b) Set the $JAVA_OPTS variable
The following syntax is for Linux or OS X:
export JAVA_OPTS="-Djava.io.tmpdir=./tmp -DXmx1024M"
c) Compile the LZX into ActionScript 3
> lzc --lzxonly test.lzx --runtime=swf10
Compiling: test.lzx to test.swf10.swf
The tmp folder will contain the generated ActionScript 3 files
tmp
├── lzccache
└── lzswf9
└── build
└── test
├── app.swf
├── build.sh
├── LzApplication.as
├── $lzc$class_basebutton.as
├── $lzc$class_basecomponent.as
├── $lzc$class_basefocusview.as
├── $lzc$class_button.as
├── $lzc$class__componentmanager.as
├── $lzc$class_focusoverlay.as
├── $lzc$class__m2u.as
├── $lzc$class__m2v.as
├── $lzc$class__m2w.as
├── $lzc$class__m2x.as
├── $lzc$class__m2y.as
├── $lzc$class__m2z.as
├── $lzc$class__m30.as
├── $lzc$class__m31.as
├── $lzc$class__mm.as
├── $lzc$class__mn.as
├── $lzc$class__mo.as
├── $lzc$class__mp.as
├── $lzc$class_statictext.as
├── $lzc$class_style.as
├── $lzc$class_swatchview.as
├── LZC_COMPILER_OPTIONS
├── LzPreloader.as
└── LzSpriteApplication.as
The folder structure follows the following scheme:
{JAVA_TEMP_FOLDER}/lzswf9/build/{LZX_FILENAME_WITHOUT_ENDING}, therefore in our case
tmp/lzswf9/build/test/
The main applicaton file is LzSpriteApplication.as, and you can look into the build.sh file to get an idea how the Flex SDK's mxmlc command is used to compile the generated source code.