Commit Graph

22 Commits

Author SHA1 Message Date
Javi Martín
26ebe619e3 Use a specific version of Ubuntu in workflows
Using ubuntu-latest might result in incompatibilities when this image
changes to a different version of Ubuntu. For example, the Ubuntu 24.04
image no longer includes imagemagick, meaning that we'll have to install
it manually when using Ubuntu 24.04.
2024-10-14 13:47:30 +02:00
Javi Martín
1c68ad3a2a Use a maintained PostgreSQL version in Docker
We're using version 13 because it's the one included in Debian Bullseye,
which is the operating system we currently use in our Dockerfile.

For consistency, we're using the same version in GitHub Actions.

Note this image requires setting a password. Otherwise we get an error:

> Database is uninitialized and superuser password is not specified.
> You must specify POSTGRES_PASSWORD to a non-empty value for the
> superuser. For example, "-e POSTGRES_PASSWORD=password" on
> "docker run".

Since now we're setting a password in the postgres service, we also need
to provide the `PGPASSWORD` environment variable (or to specify the
password in the `database.yml` file, which we do for GitLab since it
uses a separate database configuration file). Otherwise we get an error:

```
PG::ConnectionBad: connection to server at "::1", port 5432 failed:
fe_sendauth: no password supplied (PG::ConnectionBad)
```
2024-09-18 15:44:50 +02:00
Javi Martín
0163ca88c3 Remove unneeded POSTGRES_HOST option in CI workflows
Not sure whether it was needed when we included it, but everything is
working fine without it.
2024-09-18 15:35:14 +02:00
Javi Martín
baec41c43d Fix screenshots in GitHub Action when two jobs fail
The upload-artifact action does not support using the same artifact name
in different jobs (or in different matrix scenarios) since version 4,
which we started using in commit acfaada82. That meant that screenshots
were not uploaded correctly when two or more knapsack nodes failed.
2024-06-14 17:55:27 +02:00
Javi Martín
37c9e6bcde Update screenshots path in GitHub Actions
Since we upgraded to Rails 7.0 in commmit 8596f1539, the screenshots
started to be stored in `tmp/capybara`, so the step uploading
screenshots wasn't doing anything.
2024-06-14 17:50:54 +02:00
Javi Martín
acfaada82b Update upload artifact action to version 4
We were getting a warning with version 3:

Node.js 16 actions are deprecated. Please update the following actions
to use Node.js 20: actions/upload-artifact@v3. For more information see:
https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
2024-03-02 00:51:22 +01:00
Javi Martín
23e54892d5 Update setup-node action to version 4
We were getting a warning with version 3:

Node.js 16 actions are deprecated. Please update the following actions
to use Node.js 20: actions/setup-node@v3. For more information see:
https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
2024-03-02 00:29:43 +01:00
Javi Martín
3fa16bc882 Update checkout action to version 4
We were getting some warnings with version 3:

Node.js 16 actions are deprecated. Please update the following actions
to use Node.js 20: actions/checkout@v3. For more information see:
https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2024-03-01 23:46:30 +01:00
Javi Martín
e07650e09b Update upload artifact action to version 3
We were getting a warning with version 2:

The following actions uses node12 which is deprecated and will be forced
to run on node16: actions/upload-artifact@v2. For more info:
https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
2024-03-01 23:11:39 +01:00
Javi Martín
b60d2f45b8 Update checkout action to version 3
We were getting a warning with version 2:

The following actions uses node12 which is deprecated and will be forced
to run on node16: actions/checkout@v2. For more info:
https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
2024-03-01 21:58:42 +01:00
Javi Martín
ad166fba4c Setup NPM with an empty package.json file
Note that, even if we're excluding the `node_modules/` folder from
version control, we aren't adding it to Capistrano's shared folders
because, when `node_modules` is a symbolic link, NPM removes it when
running `npm install`.
2023-10-17 13:12:20 +02:00
Javi Martín
55ed40e182 Depend on a specific version of Node.js
We're choosing version 18 because if offers support for SSL 3, just
like Ruby 3.1 does.

Note we're symlinking a .nvmrc file as well, in order to make it
compatible with NVM. While the .nvmrc and .node-version files use
different formats, they both support the syntax we're using to
define the version.

The code to install Node.js in the Dockerfile is a simplification of the
code in the Rails Dockerfile template [1].

[1] https://github.com/rails/rails/blob/04c97aec8a/railties/lib/rails/generators/rails/app/templates/Dockerfile.tt#L25
2023-10-17 13:11:58 +02:00
Javi Martín
c614b0bc97 Run test coverage just on the master branch
Since we changed the way we integrate coveralls in commit 8ed8cc8b9,
we're getting 6 additional checks displayed in our pull requests.

We don't need these checks, and they only add noise. The only reason we
use coveralls is to know the test coverage in our master branch.

So we're changing the code so coveralls only runs on the master branch.

There's also a chance that the test suite will be faster because it
doesn't need to keep track of the coverage, although I haven't noticed any
significant differences during my tests.

I haven't found a more elegant way to say that a certain step should
only be run on push on master, so I'm setting the environment variable
we were already using.
2023-03-04 01:29:03 +01:00
Javi Martín
8ed8cc8b93 Use Coveralls Github Action to send test reports
Coveralls stopped working back in July when we reached build number 3790
because back when we used Travis we created builds from numbers 3791 to
35700.

After trying to change the numbers in several ways, all of them
resulting in a "No build matching CI build number" message, we're trying
the Github Action provided by Coveralls instead. In order to make it
work, we need to add the `simplecov-lcov` gem and generate the report at
`coverage/lcov.info`. Note that, for some reason, `simplecov-lcov`
doesn't seem to depend on `simplecov` and we need `simplecov` 0.18 or
later, so we're manually adding this dependency as well.
2022-11-29 14:51:22 +01:00
Senén Rodero Rodríguez
33d288f230 Use the latest available Ubuntu image to run tests
It is the Ubuntu 20.04 version at the time of writing.

Github Actions has deprecated the 18.04 we were using.
2022-08-22 17:10:33 +02:00
nathannaveen
cac6194acd chore: Set permissions for GitHub actions
Restrict the GitHub token permissions only to the required ones; this way, even if the attackers will succeed in compromising your workflow, they won’t be able to do much.

- Included permissions for the action. https://github.com/ossf/scorecard/blob/main/docs/checks.md#token-permissions

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs

[Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

Signed-off-by: nathannaveen <42319948+nathannaveen@users.noreply.github.com>
2022-06-13 00:58:13 +00:00
Javi Martín
eb4ee891c4 Reduce tests timeout in GitHub Actions
Sometimes a test gets stuck and and we have to wait until it times out
in order to check which files were being tested at the time.

The default timeout is six hours. I'm reducing it to one hour which
should still be plenty of time even on repositories with no knapsack
token.
2021-04-07 14:41:06 +02:00
Javi Martín
45693e084b Integrate coveralls with github actions
Somehow I thought it worked automatically, but we had to provide the
token.

The configuration is based on Coveralls instructions to run parallel
builds [1].

Alternatively we could use the Coveralls GitHub Action [2] which
slightly simplifies the workflow configuration and removes the
dependency of the coveralls gem. However, it also adds a dependency on
simplecov-lcov and requires configuring it to renerate LCOV files on
each run, so the benefits of using it are not that big.

[1] https://docs.coveralls.io/parallel-build-webhook
[2] https://github.com/coverallsapp/github-action/
2021-04-02 20:33:23 +02:00
Javi Martín
a504921eca Upload screenshots of failures with GitHub Actions 2021-04-02 20:30:20 +02:00
Javi Martín
cb596a8163 Fix build status badge
As mentioned in the GitHub Actions documentation [1]

> Note: Referencing the workflow file using the file path does not work
  if the workflow has a name.

[1] https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/adding-a-workflow-status-badge
2020-11-23 15:06:20 +01:00
Javi Martín
9c4d24d767 Use Knapscack Pro to run tests in parallel
Just like we used to do with Travis.

The configuration was taken from the Knapsack Pro documentation [1].

[1] https://docs.knapsackpro.com/2019/github-actions-ci-config-for-ruby-on-rails-project-with-mysql-redis-elasticsearch-how-to-run-parallel-tests
2020-11-23 14:00:36 +01:00
Javi Martín
375134ea04 Run the test suite using GitHub Actions
Using GitHub Actions has a few advantages over using Travis CI:

* More jobs can be run in parallel
* All CONSUL repositories on GitHub will be configured automatically

Besides, Travis have recently changed their policy twice. First, they
announced their site for free software projects would be shut down but
free software projects could still use their site for private projects.
And then, they limited the usage of their services for free software
projects.

Just like we used to do with Travis, we're enabling builds for pull
requests but not for pushed branches.

We're also building the master branch. Even if we never push to the
master branch directly, we're aware other CONSUL repositories do, so
we're running the tests for this case.
2020-11-23 14:00:33 +01:00