-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add a devcontainer for easier development #1256
Open
sdwilsh
wants to merge
1
commit into
crowdsecurity:master
Choose a base branch
from
sdwilsh:devcontainer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change adds a devcontainer that properly sets up a test environment such that a user has a working `cscli` and `crowdsec` command for their hub checkout. This makes it much easier to developer parsers in this repository, greatly reducing the barrier to entry. This change also adds a workflow to make sure the devcontainer can build. This could be further extended to also run tests in the devcontainer. I verified this works by running the example test command in the `README.md`: ```sh cscli hubtest run dovecot-logs INFO[26-02-2025 19:00:00] Running test 'dovecot-logs' INFO[26-02-2025 19:00:03] Test 'dovecot-logs' passed successfully (387 assertions) ─────────────────────── Test Result ─────────────────────── dovecot-logs ✅ ─────────────────────── ``` Additionally, I ran all tests with `cscli hubtest run --all`, which outputted this: https://gist.github.com/sdwilsh/6ed59b6904dac9cabbea63c55567c070
f75b2a8
to
fb9c6c6
Compare
5 tasks
sdwilsh
commented
Feb 28, 2025
Comment on lines
+14
to
+27
# As documented in https://github.com/crowdsecurity/crowdsec/issues/3183, | ||
# running ./test_env.sh sets a bunch of relative paths with simply do not work | ||
# as we need them to in a devcontainer. The following lines set absolute paths | ||
# that do work. | ||
yq -iy '.api.client.credentials_path = "/workspaces/crowdsec/tests/config/local_api_credentials.yaml"' dev.yaml | ||
yq -iy '.api.server.console_path = "/workspaces/crowdsec/tests/config/console.yaml"' dev.yaml | ||
yq -iy '.api.server.online_client.credentials_path = "/workspaces/crowdsec/tests/config/online_api_credentials.yaml"' dev.yaml | ||
yq -iy '.api.server.profiles_path = "/workspaces/crowdsec/tests/config/profiles.yaml"' dev.yaml | ||
yq -iy '.config_paths.config_dir = "/workspaces/crowdsec/tests/config/"' dev.yaml | ||
yq -iy '.config_paths.data_dir = "/workspaces/crowdsec/tests/data/"' dev.yaml | ||
yq -iy '.config_paths.notification_dir = "/workspaces/crowdsec/tests/notifications/"' dev.yaml | ||
yq -iy '.config_paths.plugin_dir = "/workspaces/crowdsec/tests/plugins/"' dev.yaml | ||
yq -iy '.crowdsec_service.acquisition_path = "/workspaces/crowdsec/tests/config/acquis.yaml"' dev.yaml | ||
yq -iy '.db_config.db_path = "/workspaces/crowdsec/tests/data/crowdsec.db"' dev.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section can go away once crowdsecurity/crowdsec#3183 is resolved (or at least the last item in that issue as of this writing).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds a devcontainer that properly sets up a test environment
such that a user has a working
cscli
andcrowdsec
command for theirhub checkout. This makes it much easier to developer parsers in this
repository, greatly reducing the barrier to entry.
This change also adds a workflow to make sure the devcontainer can
build. This could be further extended to also run tests in the
devcontainer.
I verified this works by running the example test command in the
README.md
:Additionally, I ran all tests with
cscli hubtest run --all
, whichoutputted this: https://gist.github.com/sdwilsh/6ed59b6904dac9cabbea63c55567c070