投稿時間:2022-08-14 00:17:54 RSSフィード2022-08-14 00:00 分まとめ(25件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
python Pythonタグが付けられた新着投稿 - Qiita LightGBM の木を可視化するとき日本語フォントにする https://qiita.com/CookieBox26/items/0bab0d3868b853167210 lightgbm 2022-08-13 23:54:46
python Pythonタグが付けられた新着投稿 - Qiita TA-Libのローソク足パターン認識を使う【2022/08/13 23時更新】 https://qiita.com/TKfumi/items/4744f34a10863f0d3cfb overlapstudies 2022-08-13 23:30:09
Linux Ubuntuタグが付けられた新着投稿 - Qiita 【開発者必見】UbuntuにDockerインストールして仮想マシンを構築する https://qiita.com/sakaitaka/items/6f8abd057aa999d283e7 docker 2022-08-13 23:57:25
AWS AWSタグが付けられた新着投稿 - Qiita AWS Amplify Studioを使ってみた https://qiita.com/rockinruuula1227/items/4b501675ffd9dd453d69 amplifystudio 2022-08-13 23:35:30
Docker dockerタグが付けられた新着投稿 - Qiita 【開発者必見】UbuntuにDockerインストールして仮想マシンを構築する https://qiita.com/sakaitaka/items/6f8abd057aa999d283e7 docker 2022-08-13 23:57:25
Linux CentOSタグが付けられた新着投稿 - Qiita 【開発者必見】UbuntuにDockerインストールして仮想マシンを構築する https://qiita.com/sakaitaka/items/6f8abd057aa999d283e7 docker 2022-08-13 23:57:25
GCP gcpタグが付けられた新着投稿 - Qiita [GCE] VMインスタンスを自動起動・停止させる https://qiita.com/C_HERO/items/a8c3664bad7147c9d54b computeenginegce 2022-08-13 23:01:17
技術ブログ Developers.IO AWS CDKで開発しているAWS Step FunctionsのState machine graphをローカルで視覚化する https://dev.classmethod.jp/articles/visualize-the-aws-step-functions-state-machine-graph-locally-using-the-aws-toolkit-for-visual-studio-code/ statemachinegraph 2022-08-13 14:56:16
海外TECH MakeUseOf 6 Windows Programs You Didn't Realize Steam Had https://www.makeuseof.com/windows-apps-steam/ windows 2022-08-13 14:16:14
海外TECH DEV Community Tencent Rhino-bird Open-source Training Program 2022 – SunEC sm2p256v1 Key Pairs Generation https://dev.to/hollowman6/tencent-rhino-bird-open-source-training-program-2022-sunec-sm2p256v1-key-pairs-generation-4lll Tencent Rhino bird Open source Training Program SunEC smpv Key Pairs GenerationIssue Task Requirement Task RequirementResultTested computing the signature as well as verifying the signature for comparing between secpr and secpk using SHAwithECDSA with the help of the SunEC provider The result clearly shows that secpr has a better performance than secpk with regard to SHAwithECDSA when signing But secpr has almost the same performance as secpk when verifying Benchmark Mode Cnt Score Error UnitsBenchmarkSigning secpk B thrpt ± ops sBenchmarkSigning secpk K thrpt ± ops sBenchmarkSigning secpk B thrpt ± ops sBenchmarkSigning secpk B thrpt ± ops sBenchmarkSigning secpr B thrpt ± ops sBenchmarkSigning secpr K thrpt ± ops sBenchmarkSigning secpr B thrpt ± ops sBenchmarkSigning secpr B thrpt ± ops sBenchmarkVerifying secpk B thrpt ± ops sBenchmarkVerifying secpk K thrpt ± ops sBenchmarkVerifying secpk B thrpt ± ops sBenchmarkVerifying secpk B thrpt ± ops sBenchmarkVerifying secpr B thrpt ± ops sBenchmarkVerifying secpr K thrpt ± ops sBenchmarkVerifying secpr B thrpt ± ops sBenchmarkVerifying secpr B thrpt ± ops sFurther investigation shows that before secpk was removed from JDK all the curves seem to be realized by C using the OS library instead of Java src jdk crypto ec share native libsunec impl oid c LJDK in reported the weaknesses in the implementation of the native library EC code make it necessary to remove support for future releases The most common EC curves secpr secpr and secpr had been re implemented in Java in the SunEC JCE provider After some communications with my mentor Johns Jiang he tells me that JDK introduces the optimized finite field implementations in Java Previously before that implementation was introduced pure Java realization was really slow then we use the OS library to realize all the curves so that the performance can be improved But now instead with the help of that optimized Java library Java realization takes the advantage and becomes the most efficient one it s now even comparable with the pure C realization Our flame graph also some kind confirms this as you can see here the Java Flight Recorder JFR can record the secpr methods calling stacks but it s not the case for secpk So it s likely that secpr has a better performance than secpk for signing since it s fully realized in Java and using that optimized library thus reduces the calling costs for the OS library If they are both realized in Java using the optimized method I guess there should be no difference As secpk has already been removed in JDK and now secpr does have a better performance so I guess here we will have no obvious further room for improvement Task RequirementResultAs for Elliptic curve based cryptography algorithms the curve parameters are used to generate the keys The official recommended curve parameters for SM can be seen here That curve parameters is also known as smpv since it s also a prime curve just like secpr we can use the existing implementation of secpr in the SunEC library to help us realize our implementation The OID for smpv is We first fill the curve parameters into the CurveDBThen add the OID and names The most important part is FieldGen FieldGen is used to automatically generate optimized finite field implementations which is also the library I mentioned in Task JDK for improving Java version s efficiency We need to generate two fields Integer Polynomial corresponds to parameter p and Order Field corresponds to parameter n As FFFFFFFE FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF So the Integer Polynomial shall fill just like that We can copy other parameters from secpr as they are all digit prime curve The private keys in Hex can be printed directly with no special format Since the public keys in Hex can be compressed it does have a special format that if it starts with then the keys are uncompressed and we just then concat the X and Y coordinate together The compressed ones always start with or and then only the X coordinate is needed The and is determined by that when Y coordinate is even we use use when odd In addition we have to also make sure that both X and Y coordinates are in length for Hex As the Bouncy Castle library has already fully realized the SM to ensure that the generated keys fit the smpv I also use the generated keys for signing using SMwithSM The validity of the keys can be verified during the signature verification processes during which we recover the smpv elliptic curve point from the Bouncy Castle library based on the Hex format public key If we use keys generated based on other curves like secpr error will be thrown Demo result Public Key Uncompressed AFBCAFAAABAEECDFCEEDBEAAFDDCBBFBEDBCBEBDBEDEDCBBEDDBBFFEEPublic Key AFBCAFAAABAEECDFCEEDBEAAFDDPrivate Key DADFEEADDDDDFDBFCEFDEBTo sign How are you Signed MEUCIAgvYglydHwdMkmwaRuhmkD klhVmHEBJIzCRAiEAojNkGM Tjh AmXnSPOMYgRPaWmSUXiBYGAD Verification OK Error thrown when using secpr faulty key pairs Public Key Uncompressed ACBBFFBCDABBCBEEAAABBDBCDBAEBFDABCAAEEEEBDCCBDBFEFFCCPublic Key ACBBFFBCDABBCBEEAAABBDBCDBPrivate Key ACCBDBACFECDDAAABACFDEAAEDDTo sign How are you Signed MEYCIQCktncEmfLbCrLCImgj AvZRUIQZplrqXL YwIhAOaJeSoQFnVkAJsFRYTcpCnObKoN M nPpvyException in thread main java lang IllegalArgumentException Invalid point coordinates at org bouncycastle math ec ECCurve validatePoint Unknown Source at org bouncycastle math ec ECCurve decodePoint Unknown Source at org sample SMUtil verify SMUtil java at org sample SMUtil main SMUtil java JMH Performance test for compressed and uncompressed public key generation result shows that the compressed public keys generation has a better performance than the uncompressed ones You can find the reason from the flame graph of Java Flight Recorder JFR that it s because the uncompressed ones also need to caculate the Y coordinate Hex format which takes a lot of time Benchmark Mode Cnt Score Error UnitsBenchmarkPublicKeys smpv compressed thrpt ± ops sBenchmarkPublicKeys smpv uncompressed thrpt ± ops sOur code for generating the smpv key pairs using SunEC also has a better performance than the Bouncy Castle Benchmark Mode Cnt Score Error UnitsBenchmarkKeyGeneration smpv bc thrpt ± ops sBenchmarkKeyGeneration smpv sunec thrpt ± ops s 2022-08-13 14:56:22
海外TECH DEV Community How to sort an array by date in Javascript https://dev.to/smpnjn/how-to-sort-an-array-by-date-in-javascript-2pd6 How to sort an array by date in JavascriptWe ve all been in a situation in Javascript where we have a set of data all with different dates which we want to sort by date quickly Let s look at how this works Note on Javascript Dates It should be noted that there is no such thing as a date in Javascript Instead Javascript natively only has date time That means every date comes with an associated time You can read more about Javascript Dates here How to sort by date in JavascriptThe first step to sorting by date is to ensure all your dates are in date format Suppose we have an object like this let articles name HTML Inputs date name Python Tips date name Javascript Objects date This won t really work for sorting dates since our date property is in text format Based on your specific situation you may have to handle this slightly differently For this one I m simply going to split each date by the forward slash and replace the value with a valid date value let articles name HTML Inputs date name Python Tips date name Javascript Objects date for let article of articles Split the date by the slash resulting in an array of for example let dateArr article date split Year month and day from the array We subtract from month since months start counting from in Javascript dates let year parseFloat dateArr let month parseFloat dateArr let day parseFloat dateArr Pass in the different components as year month day to get the valid date let articleDate new Date year month day Update the object article date articleDate console log articles This will output the object now with valid dates Sometimes you won t have to do this Sometimes you ll have valid dates You can check because in our above console log for articles after converting the dates they are shown formatted as Thu Mar GMT Greenwich Mean Time for example Anyway now that you ve got your dates in the standard date format let s sort them We ll use sort to do this let articles name HTML Inputs date name Python Tips date name Javascript Objects date for let article of articles Split the date by the slash resulting in an array of for example let dateArr article date split Year month and day from the array We subtract from month since months start counting from in Javascript dates let year parseFloat dateArr let month parseFloat dateArr let day parseFloat dateArr Pass in the different components as year month day to get the valid date let articleDate new Date year month day Update the object article date articleDate console log articles This will outputVM   … … … name HTML Inputs date Thu Mar GMT Greenwich Mean Time name Python Tips date Mon Apr GMT British Summer Time name Javascript Objects date Thu May GMT British Summer Time length Prototype Array undefinedlet articles name HTML Inputs date name Python Tips date name Javascript Objects date for let article of articles Split the date by the slash resulting in an array of for example let dateArr article date split Year month and day from the array We subtract from month since months start counting from in Javascript dates let year parseFloat dateArr let month parseFloat dateArr let day parseFloat dateArr Pass in the different components as year month day to get the valid date let articleDate new Date year month day Update the object article date articleDate articles sort a b gt a date b date console log articles Now an important thing to note here is that sort changes the original array So we don t need to create a new variable to store it As such articles will become permanently sorted by date from earliest date to latest If you want to do it the other way around write articles sort a b gt b date a date Why can we sort dates like numbers in Javascript It might seem confusing as to why this works Surely date is a date so why can we subtract them from each other Simply put as I alluded to earlier Javascript doesn t have date types only date time types That means every date is a date plus a time Javascript represents this under the hood as a unix time stamp which is a number representing the number of seconds or milliseconds in Javascript s case ellapsed since January st As such we can subtract dates from each other in Javascript snce they are actually represented as numbers 2022-08-13 14:49:00
海外TECH DEV Community My Google Summer of Code 2022 – Google Blockly Workspace MultiSelect Plugin https://dev.to/hollowman6/my-google-summer-of-code-2022-google-blockly-workspace-multiselect-plugin-bn7 My Google Summer of Code Google Blockly Workspace MultiSelect PluginProject LinkMy GitHubHi there In this blog post I will introduce you to my work on the plugin for selecting dragging and doing actions on multiple blocks The project is sponsored by Google Summer of Code GSoC under MIT App inventor Backgrounds AimThe project aims to enable the selection of multiple blocks at the same time and allow moving and doing actions on multiple blocks on Blockly This behavior is the same as when you try to manage your files on your Operating System You can click on the files while pressing the control key drag a rectangle to select multiple files Then move them around copying and deleting It sounds a little bit easy but actually I would say that it s not Multiple selections can become a crazy complex feature when you start thinking about the details HistoryThis feature request has remained open on GitHub Issues for six years However it was still in the discussion phase and far from the beginning of Implementation before my project began Since the Blockly community long wants this feature we base our plugin on the latest Blockly so that it can be applied to everyone s project The App Inventor uses a Blockly version that is much older so it s a pity that we can t see it work on App Inventor now Let s hope that the App Inventor can upgrade the Blockly version to the latest soon RealizationThe drag a rectangle to select feature is realized with the help of the DragSelect plugin I submitted a PR to add the pointer events so that it can work for Blockly and it will get merged soon In addition I disable the drag surface feature in Blockly which stops us from moving multiple blocks simultaneously Also there s evidence suggesting that we can perform better without a drag surface So how does the plugin work Well generally the plugin acts like an adapter It maintains its own multiple selection set which keeps currently selected blocks and make sure we always have one of the selected blocks as the selected one in Blockly core When users do some actions the plugin also passes all the actions to the other blocks in our set besides the selected one in Blockly core FunctionalitiesLet s check out what the plugin can do Additional blocks can be selected by holding the SHIFT key while clicking the new block You can also deselect the block by clicking the already selected block Clicking on the button above the trashcan is equivalent to holding or releasing the SHIFT key for switching between the multiple selection mode and the normal mode We can clear the selection by clicking on the workspace background Clicking a new block without holding SHIFT key can clear the multiple selections and change the selection to only that block Holding SHIFT key to drag a rectangle area to select can reverse their selection state for the blocks touched by the rectangle In multiple selection mode workspace dragging and block dragging will all be disabled You can only drag to draw a rectangle for selection When some of the selected blocks are in one block stack for example some top blocks and some of their children blocks are in the selection simultaneously If applicable the plugin only disconnects the selected most top block in that stack with its parent block Move along with all the children s blocks of that most top block as a whole You can also drag all the blocks to the trash can When you edit the fields while selecting multiple blocks we will automatically apply that to all the blocks with the same type There s also an MIT App Inventor only feature that has been migrated into this plugin that you can double click to collapse or expand currently selected blocks For the context menu the Duplicate will duplicate the selected most top block in the block stack and all the children blocks of that most top block The selection will be changed to all newly created duplicate blocks most top blocks For all the other items The actions to show are determined by the state of the block which the user right clicks on and the same action will be applied to all the blocks no matter their individual state We will append the currently applicable number of user selected state changing blocks and the number will only be shown when it is greater than The Add Comment Remove Comment option will add remove comment buttons to all the selected blocks The Inline Inputs External Inputs option will convert the input format with all the selected blocks The Collapse Block Expand Block option will only apply to the selected most top block in the block stack The Disable Block Enable Block option will only apply to the selected most top block in the block stack All the children blocks of that most top block will also get disabled The number in Delete X Blocks is the count of the selected most top block in the block stack as well as all children of those selected most top block Clicking on that option will delete the blocks mentioned The Help option displays just the helping information of the block the user just right clicked on We add Select all Blocks in the workspace context menu For the shortcut keys These actions will only apply to the selected most top block in the block stack when you press Ctrl A you can select all the blocks in the current workspace Ctrl C to copy the selected blocks Ctrl X to cut the selected blocks to the clipboard and Ctrl V to paste all the blocks currently in the clipboard and get all the newly pasted blocks selected Bumping neighbors after dragging to avoid overlapping is disabled in this plugin by default since I find it disturbing sometimes for multiple selections Click on a block will bring that block to the front in case Bumping neighbours is disabled UsageIf you want to integrate the plugin into your project you can add the dependency into your package json In the source code pass the workspace to the plugin and initialize the plugin and then it s done You can choose to disable double click the blocks to collapse or expand and enable bumping neighbors after dragging to avoid overlapping For the multi select controls you can also choose to hide the icon and customize the icons of each state More details can be found in the README You can also choose to integrate the plugin with other ones like the scroll options which enable the edge scroll and wheel scroll for Blockly The only thing you have to pay attention for the scroll options plugin to work is to assign the original blockDragger value required for scroll options to baseBlockDragger in our plugin Currently there s a bug that makes scroll options unable to work without the drag surface and I have also submitted a PR for fixing this it will be OK after applying the patch FinallyThat s all for this blog post Before it ends I would like to say thank you to my mentors Evan Patton and Li Li as well as the MIT App Inventor Team for guiding me throughout the project They are really supportive Also special Thanks to Beka Westberg She devoted a lot of time to giving suggestions and helping review the code We can t have this plugin without her Finally thanks for reading this blog post If you have any questions please comment and I ll reply Cheers 2022-08-13 14:44:58
海外TECH DEV Community How to check if a number is a power of two for O(1) https://dev.to/ytskk/how-to-check-if-a-number-is-a-power-of-two-for-o1-58o1 How to check if a number is a power of two for O In binary representation numbers consist of and And it just so happens that all powers of two are For example gt gt and so on When we do a comparison of number amp number we check amp which will always yield → amp gt amp 2022-08-13 14:27:00
海外TECH DEV Community Solving RISC-V Kata locally, the not-so-easy way https://dev.to/donaldsebleung/solving-risc-v-kata-locally-the-not-so-easy-way-5b06 Solving RISC V Kata locally the not so easy wayDisclaimer donaldsebleung is a community moderator on Codewars but not an official employee Any views expressed in this article solely belong to donaldsebleung and should not be considered as official Codewars stance by any means Have you heard RISC V assembly is now supported on Codewars In case you haven t heard of Codewars it s like HackerRank or LeetCode but with Proper support for test driven development TDD with production level unit testing frameworks such as JUnit for Java or Chai for Node jsA diverse range of code challenges Kata covering language fundamentals data structures and algorithms DSA mathematics advanced language features theorem proving you name itAn equally diverse communitySupport for distinct programming languages at the time of writingIf you re a developer looking to improve your programming skills through practice you should definitely give Codewars a try With that out of the way you might be wondering How do I set up a development environment for solving RISC V Kata locally For most programming languages it s simple and straightforward just install the appropriate development tools on your local machine and you re good to go For example to solve Node js Kata locally you might install on your computer Node js and npmChai Optional VSCode or another IDE of choice plus Node js specific plugins extensions to enhance the developer experienceThen copy over the solution file and unit tests from the relevant Kata and start writing code straight away But with RISC V assembly it s not that simple Assembly programs are tightly coupled with the CPU architecture and operating system they re targeting and in chances are the CPU architecture for the computer or smartphone you re reading this article on isn t RISC V it s probably x amd for most consumer PCs or aarch for smartphones and Apple Silicon Macs So if at all possible how do you run RISC V assembly programs on your local device It turns out there are a few possible ways to do this You could in no particular order of preference Run a container built for RISC V with QEMU user mode emulation This is the easiest way and also how Codewars does it On Windows and macOS you d do this with Docker Desktop and on Linux you could instead do this with Docker Engine Podman directly after installing qemu user static on Ubuntu or the equivalent package s for other distributionsPurchase a RISC V system on chip SoC such as the SiFive HiFive Unmatched board load Linux on it connect to a serial console then build and install GCC and Cgreen on the board plus optionally a suitable text editor like Emacs Nano Vim to ease the development processAs some sort of middle ground between and do the same as but on a fully emulated virt board with QEMU full system emulationAs mentioned is the easiest and also resembles exactly the Codewars execution environment but it s already well documented in so we won t cover it here is the most challenging exciting way of doing it but requires purchasing a separate board which most solvers would probably consider overkill for solving Codewars Kata We ll thus cover in this article which is nearly as exciting as but a bit simpler and does not require additional hardware investment PreparationA proper Linux environment If on Windows or macOS run a full blown Linux virtual machine VM with a hypervisor such as VirtualBox or VMware and follow the rest of this article in the VM On Windows there s also the option of WSL WSL won t work at all I bet but YMMV The reference distribution is Ubuntu If you re using an alternative Linux distribution modifications to the instructions presented in this article may be necessary or just run an Ubuntu VM anyway If you want to try running QEMU directly on Windows macOS you re on your own Either way you should be familiar with Linux and able to perform simple troubleshooting If you encounter an error like gpg command not found halfway we totally expect you to figure out to sudo apt install gnupg instead of complaining Installing dependencies setting up the virt board to boot Ubuntu for RISC VMain article RISC V Ubuntu WikiRefresh repository metadata sudo apt updateInstall the required dependencies sudo apt install qemu system misc opensbi u boot qemu qemu utilsqemu system misc Provies full system emulation for multiple architectures including RISC Vopensbi A supervisor binary interface SBI implementation SBI on RISC V is analogous to BIOS on consumer desktops laptopsu boot qemu Das U Boot universal bootloaderqemu utils Miscellaneous QEMU related utilitiesNow fetch a compressed pre installed Ubuntu server image for SiFive HiFive Unmatched which is also applicable to our virt board wget unmatched img xzDecompress unxz ubuntu preinstalled server riscv unmatched img xzWe can now boot our virt board qemu system riscv machine virt nographic m smp bios usr lib riscv linux gnu opensbi generic fw jump elf kernel usr lib u boot qemu riscv smode uboot elf device virtio net device netdev eth netdev user id eth drive file ubuntu preinstalled server riscv unmatched img format raw if virtioSince this is a fully emulated RISC V board with no hardware acceleration our Ubuntu RISC V guest takes a while to boot and fully initialize While we re waiting let s look at some of the options in the above command qemu system riscv RISC V bit system emulator machine virt Emulate the virt board which does not correspond to any real world RISC V board but is good enough for our purposes nographic Disable graphical output m Allocate MB of memory to the VM smp Emulate CPU cores bios usr lib riscv linux gnu opensbi generic fw jump elf Use OpenSBI kernel usr lib u boot qemu riscv smode uboot elf Despite the confusing name kernel use Das U Boot universal bootloader device virtio net device netdev eth netdev user id eth add virtual network interface card NIC eth use user mode networking netdev user so root privileges are not required drive file ubuntu preinstalled server riscv unmatched img format raw if virtio use the pre installed server image for our virtual diskOnce our board is fully initialized login with username ubuntu and password ubuntu You will be asked to change the password on first login Now that we ve logged in to the system any further commands in this article should be executed on our virt board unless otherwise specified Installing GCC building and installing CgreenCodewars uses the distribution provided GCC to assemble the RISC V solution and compile tests and Cgreen for unit testing To replicate this setup we ll install GCC with apt along with Cgreen build dependencies and build Cgreen from source Refresh repository metadata sudo apt updateInstall GCC and build dependencies for Cgreen g make cmake sudo apt install y gcc g make cmakeNow let s git clone Cgreen git clone recurse submodules branch Technically we don t need recurse submodules for Cgreen which recursively fetches dependencies on Git repos but it s needed for other C unit testing frameworks like Criterion and it doesn t hurt to include this option Enter cgreen pushd cgreen Build the codebase this can take a while makeIt is imperative you do not attempt to parallel build e g with j nproc I tried it it appears to build fine to completion but after installing it compiling anything involving Cgreen unit tests leads to weird linker errors that disappear once you re build Cgreen with a single thread and re install Now install sudo make installAnd update dynamic linker bindings sudo ldconfigLet s leave the Cgreen source tree popdFinally a quick test to confirm that Cgreen is correctly installed cat gt main c lt lt EOF include lt cgreen cgreen h gt int main int argc char argv return run test suite create test suite create text reporter EOF gcc main c lcgreen o main mainThe expected output Running main tests Completed main No assertions Add inspired by Multiply an example Kata setupWith GCC and Cgreen installed we can start solving RISC V Kata locally To avoid spoiling existing Kata we ll set up a hypothetical Kata known as Add where you have to fix a syntax error to get an add a b function to work The add function adds two numbers together and returns the result The Codewars setup roughly consists of the following files solution s the solver s solution in RISC V assemblysolution tests c Cgreen unit tests sample submission tests for validating the solver s solutiontests c entry point for tests that Codewarriors solvers Kata authors and translators alike need not worry aboutRISC V on Codewars does not support a preloaded section at the time of writing There s also a Codewars reporter for printing Codewars output format in unit tests instead of human friendly text output but that s irrelevant for developing our solution locally The command s used to compile and execute the code is roughly gcc solution s solution tests c tests c lcgreen o tests testsWith tests c include lt cgreen cgreen h gt TestSuite solution tests int main int argc char argv return run test suite solution tests create text reporter Let s start with a broken solution Can you spot the error Save this as solution s globl addadd addw a a retHere are some tests in solution tests c include lt cgreen cgreen h gt int add int int Describe Add BeforeEach Add AfterEach Add Ensure Add should work for fixed tests assert that add is equal to assert that add is equal to assert that add is equal to assert that add is equal to TestSuite solution tests TestSuite suite create test suite add test with context suite Add should work for fixed tests return suite Try to compile the Kata gcc solution s solution tests c tests c lcgreen o testsWhoops our solution failed to assemble Here s what you should see solution s Assembler messages solution s Error illegal operands addw a a I ll give you some time to figure out the error Now replace our broken solution with a working one in solution s globl addadd addw a a a retCompile and run the Kata now the tests should pass gcc solution s solution tests c tests c lcgreen o tests testsThe output Running solution tests test solution tests passes in ms Completed solution tests passes in ms Finally we can do random tests as well like every other supported language on Codewars Here s an updated solution tests c include lt cgreen cgreen h gt include lt time h gt int add int int Describe Add BeforeEach Add AfterEach Add Ensure Add should work for fixed tests assert that add is equal to assert that add is equal to assert that add is equal to assert that add is equal to Ensure Add should work for random tests srand time NULL for int i i lt i int a rand b rand int expected a b int actual add a b assert equal with message actual expected Expected add d d to equal d instead got d a b expected actual TestSuite solution tests TestSuite suite create test suite add test with context suite Add should work for fixed tests add test with context suite Add should work for random tests return suite Compile and run the Kata again gcc solution s solution tests c tests c lcgreen o tests testsThe output Running solution tests tests solution tests passes in ms Completed solution tests passes in ms Wrapping up next stepsPower down the board sudo systemctl poweroffThat s it I hope you enjoyed the article and happy sparring Here are some possible next steps not necessarily related to Codewars Purchase a real physical RISC V board and follow along this article with it adapting the instructions as necessaryWe loaded an out of the box OOTB Linux distribution in this article which is fun in its own right but it would be more exciting to compile our own kernel and minimal userspace and load that onto our virtual or physical board E g download the latest stable kernel from and cross compile it for RISC V do the same for BusyBox then boot our board with them The RISC V docs provides a brief outline of the process but you have to fill in the gaps which aren t trivial from my limited experience 2022-08-13 14:21:29
海外TECH DEV Community Hosting your self hosted runners on GitHub Codespaces https://dev.to/pwd9000/hosting-your-self-hosted-runners-on-github-codespaces-2elc Hosting your self hosted runners on GitHub Codespaces OverviewWelcome to another part of my series GitHub Codespaces Pro Tips In the last part we spoke about integrating GitHub with Azure DevOps and how you can use some of the great features of GitHub like Codespaces along with Azure DevOps In todays post I will share with you how you can use your GitHub Codespace not only as a development environment for working with your code but also utilising the Codespace compute power by running a Self Hosted GitHub runner inside of the Codespace at the same time We will be using a custom docker image that will automatically provision a self hosted runner agent and register it at the same time as provisioning the Codespace as part of the development environment We will also look at the Codespace Runner lifecycle By default any Active codespaces that becomes idle will go into a hibernation mode after minutes to save on compute costs so we will look at how this timeout can be configured and extended if needed We will actually be using a very similar approach for the docker image configuration based on one of my previous blog posts Create a Docker based Self Hosted GitHub runner Linux container So do check out that post also if you wanted more info on how self hosted GitHub runner containers work Getting startedAll of the code samples and examples are also available on my GitHub Codespaces Demo Repository Since Codespaces Dev containers are based on docker images we will create a custom linux docker image that will start and bootstrap a runner agent as the codespace starts up We will create the following folder structure tree in the root of our GitHub repository In your GitHub repository create a sub folder under devcontainer in my case I have called my codespace configuration folder codespaceRunner Next create the following Dockerfile You can pick any Debian Ubuntu based image FROM mcr microsoft com vscode devcontainers base bullseye Optional Install zshARG INSTALL ZSH true Optional Upgrade OS packages to their latest versionsARG UPGRADE PACKAGES false Install needed packages and setup non root user Use a separate RUN statement to add your own dependencies ARG USERNAME vscodeARG USER UID ARG USER GID USER UIDCOPY library scripts sh tmp library scripts RUN bash tmp library scripts common debian sh INSTALL ZSH USERNAME USER UID USER GID UPGRADE PACKAGES true true cd into the user directory download and unzip the github actions runnerRUN cd home vscode amp amp mkdir actions runner amp amp cd actions runner input GitHub runner version argumentARG RUNNER VERSION RUN cd home vscode actions runner amp amp curl O L RUNNER VERSION actions runner linux x RUNNER VERSION tar gz amp amp tar xzf home vscode actions runner actions runner linux x RUNNER VERSION tar gz amp amp home vscode actions runner bin installdependencies sh copy over the start sh scriptCOPY library scripts start sh home vscode actions runner start sh Apply ownership of home folderRUN chown R vscode vscode make the script executableRUN chmod x home vscode actions runner start sh Clean upRUN rm rf var lib apt lists tmp library scriptsThen create a devcontainer json file See my previous blog post on how this file can be amended with additional features and extensions name CodespaceRunner dockerFile Dockerfile Configure tool specific properties customizations Configure properties specific to VS Code vscode Add the IDs of extensions you want installed when the container is created extensions ms vscode azurecli ms vscode powershell hashicorp terraform esbenp prettier vscode tfsec tfsec Use forwardPorts to make a list of ports inside the container available locally forwardPorts Use postStartCommand to run commands each time the container is successfully started postStartCommand home vscode actions runner start sh Comment out to connect as root instead More info remoteUser vscode build args UPGRADE PACKAGES true RUNNER VERSION features terraform latest azure cli latest git lfs latest github cli latest powershell latest NOTE You can amend the GitHub runner version by amending the build args attribute RUNNER VERSION build args UPGRADE PACKAGES true RUNNER VERSION Next we will create a folder with a few scripts that will be used by our docker image Create a folder called library scripts and place the following two script inside start sh and common debian sh Let s take a closer look at each of the scripts common debian sh This script will install additional debian based tooling onto the dev container start sh start sh bin bashGH OWNER GH OWNERGH REPOSITORY GH REPOSITORYGH TOKEN GH TOKENHOSTNAME hostname RUNNER SUFFIX runner RUNNER NAME HOSTNAME RUNNER SUFFIX USER NAME LABEL git config get user name REPO NAME LABEL GH REPOSITORY REG TOKEN curl sX POST H Accept application vnd github v json H Authorization token GH TOKEN GH OWNER GH REPOSITORY actions runners registration token jq token raw output home vscode actions runner config sh unattended url GH OWNER GH REPOSITORY token REG TOKEN name RUNNER NAME labels USER NAME LABEL REPO NAME LABEL cleanup echo Removing runner home vscode actions runner config sh remove unattended token REG TOKEN trap cleanup exit INTtrap cleanup exit TERMtrap cleanup SIGINT SIGTERM home vscode actions runner run sh amp wait The second script will start up with the Codespace Dev container and bootstraps the GitHub runner when the Codespace starts Notice that we need to provide the script with some parameters GH OWNER GH OWNERGH REPOSITORY GH REPOSITORYGH TOKEN GH TOKENThese parameters environment variables are used to configure and register the self hosted github runner against the correct repository We need to provide the GitHub account org name via the GH OWNER environment variable repository name via GH REPOSITORY and a PAT token with GH TOKEN You can store sensitive information such as tokens that you want to access in your codespaces via environment variables Let s configure these parameters as encrypted secrets for codespaces Navigate to the repository Settings page and select Secrets gt Codespaces click on New repository secret Create each Codespace secret with the values for your environment NOTE When the self hosted runner is started up and registered it will also be labeled with the user name and repository name from the following lines These labels can be amended if necessary USER NAME LABEL git config get user name REPO NAME LABEL GH REPOSITORY Note on Personal Access Token PAT See creating a personal access token on how to create a GitHub PAT token PAT tokens are only displayed once and are sensitive so ensure they are kept safe The minimum permission scopes required on the PAT token to register a self hosted runner are repo read org Tip I recommend only using short lived PAT tokens and generating new tokens whenever new agent runner registrations are required Deploying the Codespace GitHub runnerAs you can see in the screenshot below my repository does not have any runners configured Navigate to your repository click on the lt gt Code dropdown and select the Codespaces tab select the Advanced option to Configure and create codespace Select the relevant Branch Region Machine type and for the Dev container configuration select the codespaceRunner config we created and click on Createcodespace It takes a few minutes to build and start the container but you can view the logs whilst the codespace is provisioning in real time To speed up codespace creation repository administrators can enable Codespaces prebuilds for a repository For more information see About GitHub Codespaces prebuilds Once the codespace is provisioned you can see the hostname of the underlying compute by typing in the terminal hostname Navigate to your repository settings page notice that there is now a self hosted GitHub runner registered and labeled with your user name and repo name The runner name matches the Codepsace hostname Managing Codespace Runner lifecycleWhen you stop your codepsace the self hosted runner will not be removed but will only go into an Offline state and when you start the codespace up again the runner will be available again Also as mentioned by default any Active codespaces that are not stopped manually will be idle and go into a hibernation mode after minutes to save on compute costs Let s take a look at how we can amend codespaces lifecycle In the upper right corner of any page click your profile photo then click Settings and in the Code planning and automation section of the sidebar click Codespaces Under Default idle timeout enter the time that you want then click Save The time must be between minutes and minutes hours ConclusionAs you can see it is pretty easy to run self hosted action runners inside of your Codespace and utilize the compute power of the dev container itself By doing this we can solve a few problems with one solution Cost Not wasting cost and compute power by adding compute separately for self hosted runners alongside Codespaces Administration Having both services running on the same compute and sharing the same configuration and tooling saves time on administration and maintenance Availability Having self hosted runners available as part of the running codespace IMPORTANT Do note that making use of runner labels is very important when triggring running actions against runners or runner groups provisioned on a Codespace Hence each runner is labeled with the user name and repo name I hope you have enjoyed this post and have learned something new You can also find the code samples used in this blog post on my published Github page ️ AuthorLike share follow me on GitHub Twitter LinkedIn Marcel LFollow Microsoft DevOps MVP Cloud Solutions amp DevOps Architect Technical speaker focused on Microsoft technologies IaC and automation in Azure Find me on GitHub 2022-08-13 14:10:07
海外TECH DEV Community Daha Temiz Kod Yazmak İçin İpuçları https://dev.to/gulsenkeskin/daha-temiz-kod-yazmak-icin-ipuclari-5dia Daha Temiz Kod Yazmak İçin İpuçlarıKod larımızıdaha okunabilir ve temiz hale getirmek için bir çok makaleden derlenmişkolay kullanılabilir ve kısa ipuçları Erken Dönüş Return Early Tasarım Modelini Kullanın function saveItem item if item null console log Validating if item isValid console log Saving item item save Yukarıdaki örnekte yanlışbir şey yok ancak içiçe if fadeleri kullanarak yuvalama yapmak yerine item değeri null ise veya valid değilse early return erken dönüş kullanarak aşağıdaki gibi fonsiyondan çıkmasınısağlayabiliriz function saveItem item if item null return console log Validating if item isValid return console log Saving item item save Fonksiyon Parametreleri İçin Object Destructuring Nesne Yıkımı KullanınBir nesneyi parametre olarak alan ve yeni bir değer döndürmek için o nesne üzerinde bir tür işlem gerçekleştiren bir fonksiyonumuz olduğunu varsayalım Nesne yok etmeyi object destructuring kullanmadan şöyle bir şey elde edebiliriz function getFullName person const firstName person firstName const lastName person lastName return firstName lastName Bu kullanım şekli gerçekten ihtiyacımız olmadığında da firstName ve lastName olmak üzere iki geçici referans oluşturur Bunu uygulamanın daha iyi bir yolu nesne yıkımını object destructuring kullanmaktır Bir satırda hem firstName hem de lastName değerlerini almak için person nesnesini yok destruct edebiliriz function getFullName person const firstName lastName person return firstname lastName Ve parametreleri destruct ederek bu kodu daha zarif bir hala getirebiliriz function getFullName person const firstName lastName person return firstname lastName Pure Saf FonksiyonlarıKullanarak Yan Etkilerden Side Effects Kaçının Fonksiyon yazarken o fonksiyonun dışındaki değişkenleri değiştirmekten kaçınmak en iyisidir let items function changeNumber number items number return items changeNumber Bu fonksiyonu çağırdığımızda item değişkeninin değerini değiştirdiğimiz için bu kullanım istenmeyen durumlara yol açar Bunun yerine pure saf fonksiyon kullanarak fonksiyonu aşağıdaki gibi yeniden yazabiliriz function addThree number return number Harici değişkeni kaldırdığımız için fonksiyonun davranışıartık tamamen öngörülebilir hale geldi SRP Tek Sorumluluk İlkesi Sadece bir şey yapan kısa fonksiyonlar yazın Bu kodun içiçe yapıya sahip olmamasıveya ikiden fazla girinti düzeyine sahip olmamasıgerektiği anlamına gelir Yanlışkullanım function signUpAndValidate Yerine function signUp function validate AnlamlıDeğişken ve Fonksiyon AdlarıKullanın Fonksiyonlar eylemleri gerçekleştirir bu nedenle fonksiyonlarınızıadlandırırken filleri kullanın badfunction passwordValidation goodfunction validatePassword Diziler için çoğul kullanınconst animal cat dog bird const animals cat dog bird Callback fonksiyonlarında yineleme yaparken anlamlıisimlendirmeler kullanınanimals forEach a gt console log a do thisanimals forEach animal gt console log animal Kodunuzu yeniden kullanılabilir ve anlaşılır kılmak için benzer değişkenleri ve fonksiyonlarıgruplayın DRY İlkesi Kendinizi tekrar etmeyin Aynıkodu birden çok yerde kullanmanız gerekiyorsa onu bir fonksiyona dönüştürün Okunabilir Kod Oluşturmak İçin BoşSatırlar Kullanınfunction saveItem item if item null return console log Validating if item isValid return console log Saving item item save function Delete item console log Delete item item delete function saveItem item if item null return console log Validating if item isValid return console log Saving item item save function Delete item console log Delete item item delete Birim Unit Testini kullanın ve Teste DayalıGeliştirme TDD Test Driven Development Uygulayın Unit testleri sayesinde kodda değişiklik yapmak ve hatalarıazaltmak daha kolay hale gelir Yazılım geliştirmede gereksinimlerin belirli test senaryolarına dönüştürüldüğüve ardından yazılımın yeni testleri geçecek şekilde geliştirildiği Test OdaklıGeliştirme TDD adıverilen bir süreçvardır Tasarımıyap Testi yaz Geliştirmeyi yaz Testi yapTDD süreci aşağıdaki adımlarıiçerir Belirtilen gereksinimlere göre yazılım geliştirici bir test senaryosu yazarBu testler gerçekleştirilir ve bir özelliğin geliştirilmesinden önce yazıldığıiçin başarısız olmasıbeklenirGeliştirme ekibi tarafından testin başarıyla geçmesi için kodlama yapılırBütün testlerin başarılıolmasısağlanırKod tekrar gözden geçirilir ve düzenlenir İyileştirme veya temizleme yapılır Gereksiz Yorumlar Yazmaktan KaçınınKodunuzda gereksiz yorumlardan kaçınmak için değişkenler işlevler veya dosyalar için anlamlıadlar kullanın Bir yorum eklemek üzereyken kendinize şu soruyu sorun Bu yoruma gerek kalmayacak şekilde kodu nasıl iyileştirebilirim Kodu geliştirin ve ardından daha da net hale getirmek için belgeleyin Steve McConnell RefaktörBir kodu yeniden düzenlemek gerçekten iyi bir beceridir neler olup bittiğinin farkında olmanızısağlar ve yeniden düzenleme yaparken daha iyi hale gelir bir süre sonra kodunuza geri dönmek ve geliştirmek her zaman iyi bir uygulamadır Tüm Değişken Bildirimlerinizi Bir Arada Tutun Projeleriniz büyümeye başladığında sınıflarınızın muhtemelen birçok değişkeni olacaktır İlk olarak tüm değişken bildirimlerinizi sayfanın en üstünde veya en azından bir yerde bir arada tutmalısınız bu her türlüaramayıhızlandırır Doğru Mimariyi SeçinProjelerinizi oluşturmak için kullanabileceğiniz birçok paradigma ve mimari vardır Bu ipucunun en iyisini seçmekle ilgili değil ihtiyaçlarınız için doğru olanıseçmekle ilgili olduğuna dikkat edin Gereksinimler ve tasarım olmadan programlama boşbir metin dosyasına hata ekleme sanatıdır Louis SrygleyÖrneğin Model View Controller MVC modeli web geliştirmede popülerdir çünkükodunuzu düzenli tutmaya yardımcıolur ve bakım çabalarınıen aza indirecek şekilde tasarlanır Sihirli Sayı Sihirli bir sayı net bir anlamıolmayan bir sayıatadığımız anlamına gelir Bazen belirli bir amaçiçin bir değer kullanırız ve değeri anlamlıbir değişkene atamayız Bu durum kodunuzu okuyan kişinin bu sayının amacınıanlamamasına neden olur Bad practicefor let i i lt i do something Good practicelet NUMBER OF STUDENTS for let i i lt NUMBER OF STUDENTS i do something Tasarım KalıplarınıKullanınSOLID Tasarım İlkeleriSingle Responsibility Principle Tek Sorumluluk İlkesi Bir sınıfın yalnızca bir işi olmalıdırOpen Closed Principle Açık Kapalıİlkesi Bir sınıf genişletmeye açık ancak değişikliğe kapalıolmalıdır Liskov Substitution Principle Liskov Değiştirme İlkesi Bir programdaki nesneler programın doğruluğunu değiştirmeden alt türlerinin örnekleriyle değiştirilebilir olmalıdır Interface Segregation Principle Arayüz Ayrıştırma İlkesi Bir istemci asla kullanmadığıbir arayüzüuygulamaya zorlanmamalıdır Dependency Inversion Principle Bağımlılık Tersine Çevirme Prensibi Yüksek seviyeli modül düşük seviyeli detaya değil yüksek seviyeli genellemeye dayanmalıdır Diğer Tasarım KalıplarıComposing Objects Principle Nesneleri Oluşturma İlkesi Sınıflar kalıtım inheritance yerine toplama yoluyla kodun yeniden kullanımınısağlamalıdır Demeter Yasası Principle of Least Knowledge En Az Bilgi Prensibi Sınıflar mümkün olduğunca az sayıda diğer sınıfıbilmeli ve bunlarla arayüz oluşturmalıdır Abstraction Soyutlama Yalnızca ilgili bilgileri göstererek basitleştirinEncapsulation Kapsülleme Nitelikleri ve davranışlarıbir nesnede gruplama ve gerektiğinde özellikleri açığa çıkarma Bir grup kod sıklıkla birlikte kullanılıyorsa kapsüllmeyi kullanın Decomposition Ayrıştırma Bir varlığıayrıayrıuygulanabilecek parçalara ayırmaBir sınıf çok büyükse ayrıştırma decomposition kullanın Generalization Genelleme Başka yerlerde yeniden kullanılabilecek sınıfların ortak özelliklerini çarpanlarına ayırma Aynıkod küçük değişikliklerle birlikte kod tabanının birden çok bölümünde kullanılıyorsa genellemeyi kullanın Coupling and Cohesion Gevşek bağlımodüller daha az bağımlıdır ve yeniden kullanımıdaha kolaydır yüksek uyum ise net bir amacıolan ve olmasıgerekenden daha karmaşık olmayan bir modülütanımlar Bir yerdeki değişiklik diğer birçok parçada değişikliğe neden oluyorsa bu sıkıbağlantıanlamına gelir Inheritance Kalıtım Alt sınıfların bir üst sınıftan miras aldığıveya bir arabirim aracılığıyla uygulayan nitelik veya davranışlar Information Hiding Bilgi Gizleme Modüller yalnızca yapmasıgereken bilgilere erişebilmelidir Information Hiding Endişelerin Ayrımı Farklımodüllerde farklıendişeler olmalıdırKISS principle KISS ilkesi çoğu sistemin karmaşık hale getirilmek yerine basit tutulursa en iyi şekilde çalıştığınıbelirtir bu nedenle tasarımda basitlik temel hedef olmalıve gereksiz karmaşıklıktan kaçınılmalıdır Sandi Metz s KurallarıClass lar da satırdan fazla kod olamazMethodlar ve fonksiyonlarda satırdan fazla kod olamazBir method a en fazla parametre iletinController lar yalnızca bir nesneyi başlatabilir Bir geliştirici olarak yalnızca bir şeyleri teslim etme konusunda endişelenmememiz gerektiğini unutmayın Bundan daha fazlasıdır bu kodu desteklemesi gereken bir sonraki geliştiriciyi düşünmekle ilgilidir Bu yüzden lütfen bir sonraki projenizde bulmak istediğiniz kodunuzu okunaklıbir şekilde bırakın Resources Many thanks to Dominic Duke Lauren Alexander Claudia Sanjuan Steve McConnell Ahmet Cokgungordu Awedis Keofteian Amal Hasni Kay Jan Wong Joel Lee Shoaib Mehediand irgwc amp mpid amp aid axAKZAA amp utm medium digital affiliate amp utm campaign amp utm source impactradius 2022-08-13 14:03:32
海外TECH DEV Community My Summer of Bitcoin 2022 Project - CI for CADR https://dev.to/hollowman6/my-summer-of-bitcoin-2022-project-ci-for-cadr-2pid My Summer of Bitcoin Project CI for CADR SynopsisBefore the Summer of Bitcoin project Cryptoanarchy Debian Repo CADR lacked Continuous Integration CI which troubles the new coming contributors because setting up the developing environment can be complex I finally successfully implemented the CI using GitHub Actions default runners The CI can be triggered manually or by sending PRs as well as pushing directly to the master branch The CI is divided into jobs The first one is the build job It builds the running podman environment image uploads the image to Artifacts for reuse Then with the podman environment builds the CADR packages checks their sha sum and then uploads the built Debian packages as well as their sha sum values to Artifacts The second one is the test job It runs when the build job finishes The testing jobs are run in parallel for each package The test job first downloads the built images and packages Artifacts uploaded in the build job then use make test here basic and make test here upgrade for package name to run tests Road of Implementation First tryAt first I ignored the fact that there already exists a dockerfile for CADR running although it was not for building and setup my own dockerfile from scratch by adding dependencies when I encounter any errors My own dockerfile turned out to work fine on GitHub Actions for the building process but failed for the test process Initially I thought it was some more dependency issues since the test can work on my own computer When checking the logs I found that it s due to the unshare issue Then I noticed that adding a privileged parameter can fix the unshare issue for docker But then a systemd issue just came after it Finally I noticed the dockerfile in the codebase that already exists for CADR and just as how it works I made the systemd to start as the first process VOLUME sys fs cgroup CMD lib systemd systemd and add tmpfs tmp tmpfs run tmpfs run lock v sys fs cgroup sys fs cgroup ro as additional parameters to share some host machine resources and make it as the daemon container Operations are done using docker exec to attach to the container But still it doesn t fix the systemd issue Finally I switched to podman and the systemd issue got fixed it supports systemd true because I occasionally found this article when I Googled the issue However a new issue occurs suggesting failed to override dbcache Can t see any errors from the workflow logs even though the missing bc dependency has been fixed and I can confirm that the command here works correctly in the container running on my PC Moreover when I manually skip the test just mentioned the test further shows that there is an unneeded reindex Which suggests that it s related to issue maybe Have opened an issue here I can skip that test but further error suggesting electrs is not available It can be fixed with this PREven if those issues are fixed another platform may still be needed since the full test requires too much space Only testing the regtest part will be fine with no space issue Fixing the testsThe first issue is to find out why overriding dbcache fails This takes me quite a few weeks to find out the solution Originally when determining bitcoin dbcache size bc is invoked But bc is not guaranteed to be installed thus it can fail Then instead of doing maths wizardry I submitted a PR to just match on ranges RAM lt gt default dbcache RAM lt gt dbcache RAM gt gt dbcache However the failed to override dbcache still exists when running in GitHub Actions workflow with this PR It s very weird as when I run the test manually using the same methods from the workflow with the podman container on my PC such an issue won t appear So the issue seems to belong to GitHub Actions workflow environment only even though it s running in the container Then after a lot of trial and error I finally found the culprit By referring to PR previously the debcrafter dropped all capabilities which seems to cause errors when the host kernel capabilities do not match those known to setpriv We need to only drop supported capabilities by the current kernel Then I submitted a PR to fix this and got merged The second issue is to find out why the unneeded reindex error exists I noticed that although the test failed on test here basic electrs with unneeded reindex when running make test running make test here basic electrs alone won t fail So prior to fixing this issue my guess was that maybe it s still related to issue issue which is that after updating existing non pruned nodes in experimental reindex was used despite pruning not being changed Or the test environment didn t get cleaned up before test here basic electrs when executing make test My final result proves that the later is right and submitted a PR to clean up the chain mode marker since we want it to be clean with package clean install shI also submitted a PR to force linked hash map version to be for fixing the build issue of debcrafter that just came up during the project period The test can be successful on GitHub Actions when only tested with regtest and after PR get merged Research on cloud providerI also researched on which cloud service to use as we were intended to use a GItHub self hosted runner As I checked on cloud service providers AWS Google Cloud and Azure I find that GitHub Actions uses Azure as their default runners to build a GitHub self hosted runner Azure would be a good choice if we use the same provider as the GitHub default hosted runner Also Azure has a trial period with dollars for one month when starting a new account so we can start free while other cloud service providers don t offer such a great discount Investigation on other possible CI platformsI find out that unlike GitHub Actions that runs CI in a virtual machine Travis CI GitLab CI CD Jenkins all run the CI predefined Docker containers without without systemd support Then it would be not possible to run a systemd supported podman container inside such a container Azure DevsOps is a valid one for our use case and I also tried to use it Then I noticed that for a single CI job each step it only allows hour maximum otherwise it would get cancelled while our build job as well as full net test job last much longer than hour it s also not suitable for us Then finally the GitHub Actions would be the only good choice to have Self hosted runners for GitHub ActionsI had also tried to use Azure Virtual Machines service by myself to set up Self hosted runners for GitHub Actions but it seems like the environment doesn t automatically get cleaned each time and is contaminated from previous runs Divide and ConquerFinally I came up with a new way for testing We can use the divide and conquer to bypass the short of disk space issue as well as the contaminated running environment issue when running tests on both the mainnet and regtest I can see that the make test is composed of make test here basic and make test here upgrade for package name we can just use the matrix in GitHub Actions to test each package in separate environments and then the disk space would be enough and PR can be closed because we now always have a clean environment Then I successfully implemented and tested that method and it works So right now it s the full test and I have reached the project goal with even a solution that has no money cost for CI building and testing The CI can be successful if the previous tests fixing PRs get merged first Final DeliverablesAfter my mentor Kixunil s review I began to use locked parameter to make cargo use cargo lock which contains correct versions Also I fixed a security issue make a user account user and built tested with user and made to upload the shasum result for the built deb packages afterwards so people can check hashes In addition I fixed tests for bitcoin regtest after setting bitcoind nosettings enabled in PR Then there should be some kind of bug in core for this wallet location difference in the GitHub runner and the physical machine so the PR gets closed and another solution that makes tests independent of wallet location was committed The CI runs successfully with the above changes and everything works fine nothing left to do ConclusionMy Summer of Bitcoin project is a great experience for me as I learned a lot about Bitcoin and related DevOps knowledge If you are interested in Bitcoin and would like to start contributing to Cryptoanarchy Debian with my work you can easily fork the repo and add more test or new packages by committing the code to your fork s master branch on GitHub the CI will help you build the deb packages and locate possible errors no need to setup the developing environment on your computer again Summary of PRs Merged SoB Add GitHub workflow for CIFix libcap ng is too old for all capsRemove bc dependency for overriding dbcacheChange all apt into apt get in testTry more times to test connecting to electrs regtestSet bitcoind log file under var logSet bitcoind nosettings enabled by default Closed as resolved in another way Issue Bug Test failed for bitcoin regtest with error unneeded reindex for test here basic electrsFix unneeded reindex error running testsFix tests for bitcoin regtest after setting bitcoind nosettings enabledForce linked hash map version to be rustyline downgrade to to fix compiling issue 2022-08-13 14:03:00
ニュース BBC News - Home Salman Rushdie: Author believed fatwa was old and life relatively normal https://www.bbc.co.uk/news/world-us-canada-62532200?at_medium=RSS&at_campaign=KARANGA author 2022-08-13 14:45:24
ニュース BBC News - Home Nature reserve fire caused by barbecue, firefighters say https://www.bbc.co.uk/news/uk-england-dorset-62532328?at_medium=RSS&at_campaign=KARANGA beach 2022-08-13 14:29:43
ニュース BBC News - Home Medusa festival: One killed as strong winds cause stage collapse in Spain https://www.bbc.co.uk/news/world-europe-62531942?at_medium=RSS&at_campaign=KARANGA valencia 2022-08-13 14:05:22
ニュース BBC News - Home Horrifying, ghastly: Authors condemn attack on Salman Rushdie https://www.bbc.co.uk/news/world-us-canada-62532032?at_medium=RSS&at_campaign=KARANGA rushdie 2022-08-13 14:30:22
ニュース BBC News - Home The Hundred: Alana King becomes the Hundred's new hero with hat-trick https://www.bbc.co.uk/sport/cricket/62534770?at_medium=RSS&at_campaign=KARANGA shane 2022-08-13 14:20:22
北海道 北海道新聞 胆振管内509人感染 日高管内は70人 新型コロナ https://www.hokkaido-np.co.jp/article/717471/ 新型コロナウイルス 2022-08-13 23:34:06
北海道 北海道新聞 ミニトマト農家に外国人留学生派遣 人手不足解消と交流両立 札幌の物流会社 https://www.hokkaido-np.co.jp/article/717424/ 人手不足 2022-08-13 23:28:46
北海道 北海道新聞 スズメバチの巣利用しクモ越冬 北大苫小牧研究林の調査で確認 https://www.hokkaido-np.co.jp/article/717466/ 越冬 2022-08-13 23:13:48

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)